@@ -308,7 +308,7 @@ def genai_gen_image(model, prompt, num_inference_steps, generator=None):
308
308
309
309
310
310
def genai_gen_image2image (model , prompt , image , num_inference_steps , generator = None ):
311
- image_data = ov .Tensor (np .array (image . getdata ()). reshape ( 1 , image . size [ 1 ], image . size [ 0 ], 3 ). astype ( np . uint8 ) )
311
+ image_data = ov .Tensor (np .array (image )[ None ] )
312
312
image_tensor = model .generate (
313
313
prompt ,
314
314
image = image_data ,
@@ -321,8 +321,8 @@ def genai_gen_image2image(model, prompt, image, num_inference_steps, generator=N
321
321
322
322
323
323
def genai_gen_inpainting (model , prompt , image , mask , num_inference_steps , generator = None ):
324
- image_data = ov .Tensor (np .array (image . getdata ()). reshape ( 1 , image . size [ 1 ], image . size [ 0 ], 3 ). astype ( np . uint8 ) )
325
- mask_data = ov .Tensor (np .array (mask . getdata ()). reshape ( 1 , mask . size [ 1 ], mask . size [ 0 ], 3 ). astype ( np . uint8 ) )
324
+ image_data = ov .Tensor (np .array (image )[ None ] )
325
+ mask_data = ov .Tensor (np .array (mask )[ None ] )
326
326
image_tensor = model .generate (
327
327
prompt ,
328
328
image = image_data ,
@@ -335,7 +335,7 @@ def genai_gen_inpainting(model, prompt, image, mask, num_inference_steps, genera
335
335
336
336
337
337
def genai_gen_visual_text (model , prompt , image , processor , tokenizer , max_new_tokens , crop_question ):
338
- image_data = ov .Tensor (np .array (image . getdata ()). reshape ( 1 , image . size [ 1 ], image . size [ 0 ], 3 ). astype ( np . uint8 ) )
338
+ image_data = ov .Tensor (np .array (image )[ None ] )
339
339
out = model .generate (prompt , image = image_data , do_sample = False , max_new_tokens = max_new_tokens )
340
340
return out .texts [0 ]
341
341
0 commit comments