siriuszeina commited on
Commit
b678a40
1 Parent(s): e73ed2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -42,10 +42,8 @@ model = load_model()
42
  labels = load_labels()
43
 
44
  #image: PIL.Image.Image
45
- def predict(url: str, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
46
  _, height, width, _ = model.input_shape
47
- response = requests.get(url)
48
- image = PIL.Image.open(BytesIO(response.content))
49
  image = np.asarray(image)
50
  image = tf.image.resize(image, size=(height, width), method=tf.image.ResizeMethod.AREA, preserve_aspect_ratio=True)
51
  image = image.numpy()
@@ -77,8 +75,9 @@ with gr.Blocks(css="style.css") as demo:
77
  with gr.Row():
78
  with gr.Column():
79
  #image = gr.Image(label="Input", type="pil")
80
- url = gr.Textbox("")
81
-
 
82
  score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
83
  run_button = gr.Button("Run")
84
 
 
42
  labels = load_labels()
43
 
44
  #image: PIL.Image.Image
45
+ def predict(image: PIL.Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
46
  _, height, width, _ = model.input_shape
 
 
47
  image = np.asarray(image)
48
  image = tf.image.resize(image, size=(height, width), method=tf.image.ResizeMethod.AREA, preserve_aspect_ratio=True)
49
  image = image.numpy()
 
75
  with gr.Row():
76
  with gr.Column():
77
  #image = gr.Image(label="Input", type="pil")
78
+ url = gr.Textbox(value="https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png")
79
+ response = requests.get(url)
80
+ image = PIL.Image.open(BytesIO(response.content))
81
  score_threshold = gr.Slider(label="Score threshold", minimum=0, maximum=1, step=0.05, value=0.5)
82
  run_button = gr.Button("Run")
83