lovelyai999 commited on
Commit
efc684e
·
verified ·
1 Parent(s): 54130af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -18,10 +18,10 @@ def predict_and_draw(input_image):
18
  #input_image=ImageToCV(input_image)
19
 
20
  instructions = model.predict(input_image)
21
- img = cv2.imread(input_image, cv2.IMREAD_GRAYSCALE)
22
  img = cv2.resize(img, (IMAGE_SIZE, IMAGE_SIZE))
23
  # 創建一個新的白色圖像
24
- image = np.zeros((IMAGE_SIZE, IMAGE_SIZE), dtype=np.uint8)
25
 
26
  # 執行每條繪圖指令
27
  for instruction in instructions:
@@ -30,13 +30,13 @@ def predict_and_draw(input_image):
30
  import traceback
31
  traceback.print_exc()
32
  #image=CVtoImage(image)
33
- return img, image, "\n".join(instructions)
34
 
35
 
36
  iface = gr.Interface(
37
  fn=predict_and_draw,
38
  inputs=gr.Image(type="filepath"),
39
- outputs=[ gr.Image(type="numpy" ,image_mode="L" ,label="Input Image"), gr.Image(type="numpy" ,image_mode="L" ,label="Output Image"), gr.Textbox(label="Generated Instructions" ,show_copy_button=True)],
40
  title="Image to Drawing Instructions",
41
  description="Upload an image, and the model will predict drawing instructions based on it."
42
  )
 
18
  #input_image=ImageToCV(input_image)
19
 
20
  instructions = model.predict(input_image)
21
+ img = cv2.imread(input_image)
22
  img = cv2.resize(img, (IMAGE_SIZE, IMAGE_SIZE))
23
  # 創建一個新的白色圖像
24
+ image = np.zeros((IMAGE_SIZE, IMAGE_SIZE, 3), dtype=np.uint8)
25
 
26
  # 執行每條繪圖指令
27
  for instruction in instructions:
 
30
  import traceback
31
  traceback.print_exc()
32
  #image=CVtoImage(image)
33
+ return CVtoImage(img), CVtoImage(image), "\n".join(instructions)
34
 
35
 
36
  iface = gr.Interface(
37
  fn=predict_and_draw,
38
  inputs=gr.Image(type="filepath"),
39
+ outputs=[ gr.Image(label="Input Image"), gr.Image(label="Output Image"), gr.Textbox(label="Generated Instructions" ,show_copy_button=True)],
40
  title="Image to Drawing Instructions",
41
  description="Upload an image, and the model will predict drawing instructions based on it."
42
  )