Spaces:
Sleeping
Sleeping
Commit
·
c0f0f0d
1
Parent(s):
81c41e8
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import io
|
2 |
import torch
|
|
|
3 |
import numpy as np
|
4 |
import gradio as gr
|
5 |
import matplotlib.pyplot as plt
|
@@ -32,7 +33,7 @@ def model_inference(img, prob_threshold, classes_to_show):
|
|
32 |
|
33 |
img = Image.fromarray(img)
|
34 |
|
35 |
-
pixel_values = feature_extractor(img, return_tensors="
|
36 |
|
37 |
with torch.no_grad():
|
38 |
outputs = model(pixel_values, output_attentions=True)
|
@@ -97,12 +98,13 @@ classes_to_show = gr.components.Textbox(
|
|
97 |
)
|
98 |
|
99 |
inputs = [image_in, prob_threshold_slider, classes_to_show]
|
100 |
-
|
|
|
101 |
|
102 |
gr.Interface(fn=model_inference,
|
103 |
inputs=inputs,
|
104 |
outputs=image_out,
|
105 |
title=title,
|
106 |
description=description,
|
107 |
-
examples=
|
108 |
).launch()
|
|
|
1 |
import io
|
2 |
import torch
|
3 |
+
import pathlib
|
4 |
import numpy as np
|
5 |
import gradio as gr
|
6 |
import matplotlib.pyplot as plt
|
|
|
33 |
|
34 |
img = Image.fromarray(img)
|
35 |
|
36 |
+
pixel_values = feature_extractor(img, return_tensors="pt").pixel_values
|
37 |
|
38 |
with torch.no_grad():
|
39 |
outputs = model(pixel_values, output_attentions=True)
|
|
|
98 |
)
|
99 |
|
100 |
inputs = [image_in, prob_threshold_slider, classes_to_show]
|
101 |
+
img_input = gr.Image(type='pil')
|
102 |
+
example_images = gr.Dataset(components=[img_input], samples=[[path.as_posix()] for path in sorted(pathlib.Path('examples').rglob('*.*'))])
|
103 |
|
104 |
gr.Interface(fn=model_inference,
|
105 |
inputs=inputs,
|
106 |
outputs=image_out,
|
107 |
title=title,
|
108 |
description=description,
|
109 |
+
examples=example_images
|
110 |
).launch()
|