siriuszeina commited on
Commit
eee050e
·
verified ·
1 Parent(s): 4040b31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -43,10 +43,10 @@ model = load_model()
43
  labels = load_labels()
44
 
45
  #image: PIL.Image.Image
46
- def predict(img: bytes, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
47
  _, height, width, _ = model.input_shape
48
  #response = requests.get(url)
49
- image = PIL.Image.open(img)
50
 
51
  image = np.asarray(image)
52
  image = tf.image.resize(image, size=(height, width), method=tf.image.ResizeMethod.AREA, preserve_aspect_ratio=True)
@@ -77,9 +77,9 @@ with gr.Blocks(css="style.css") as demo:
77
  gr.Markdown(DESCRIPTION)
78
  with gr.Row():
79
  with gr.Column():
80
- #image = gr.Image(label="Input", type="filepath")
81
  #url = gr.Textbox("https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png")
82
- img = gr.File(type="binary")
83
  score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
84
  run_button = gr.Button("Run")
85
  with gr.Column():
@@ -93,7 +93,7 @@ with gr.Blocks(css="style.css") as demo:
93
 
94
  run_button.click(
95
  fn=predict,
96
- inputs=[img, score_threshold],
97
  outputs=[result, result_json, result_text],
98
  api_name="predict",
99
  )
 
43
  labels = load_labels()
44
 
45
  #image: PIL.Image.Image
46
+ def predict(image: PIL.Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
47
  _, height, width, _ = model.input_shape
48
  #response = requests.get(url)
49
+ #image = PIL.Image.open(img)
50
 
51
  image = np.asarray(image)
52
  image = tf.image.resize(image, size=(height, width), method=tf.image.ResizeMethod.AREA, preserve_aspect_ratio=True)
 
77
  gr.Markdown(DESCRIPTION)
78
  with gr.Row():
79
  with gr.Column():
80
+ image = gr.Image(label="Input", type="pil")
81
  #url = gr.Textbox("https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png")
82
+ #img = gr.File(type="binary")
83
  score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
84
  run_button = gr.Button("Run")
85
  with gr.Column():
 
93
 
94
  run_button.click(
95
  fn=predict,
96
+ inputs=[image, score_threshold],
97
  outputs=[result, result_json, result_text],
98
  api_name="predict",
99
  )