Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ og_model = 'facebook/detr-resnet-50'
|
|
9 |
image_processor = DetrImageProcessor.from_pretrained(og_model)
|
10 |
model = AutoModel.from_pretrained("taroii/notfinetuned-detr-50")
|
11 |
|
12 |
-
def
|
13 |
with torch.no_grad():
|
14 |
# load image and predict
|
15 |
inputs = image_processor(images=image, return_tensors='pt')
|
@@ -28,8 +28,13 @@ def query(image):
|
|
28 |
labels = [f"{id2label[class_id]} {confidence:.2f}" for _, confidence, class_id, _ in detections]
|
29 |
frame = box_annotator.annotate(scene=image.copy(), detections=detections, labels=labels)
|
30 |
|
31 |
-
plot_image(frame, (16, 16))
|
32 |
|
33 |
-
return labels
|
34 |
|
35 |
-
gr.Interface
|
|
|
|
|
|
|
|
|
|
|
|
9 |
image_processor = DetrImageProcessor.from_pretrained(og_model)
|
10 |
model = AutoModel.from_pretrained("taroii/notfinetuned-detr-50")
|
11 |
|
12 |
+
def predict(image):
|
13 |
with torch.no_grad():
|
14 |
# load image and predict
|
15 |
inputs = image_processor(images=image, return_tensors='pt')
|
|
|
28 |
labels = [f"{id2label[class_id]} {confidence:.2f}" for _, confidence, class_id, _ in detections]
|
29 |
frame = box_annotator.annotate(scene=image.copy(), detections=detections, labels=labels)
|
30 |
|
31 |
+
return plot_image(frame, (16, 16))
|
32 |
|
33 |
+
#return labels
|
34 |
|
35 |
+
gr.Interface(
|
36 |
+
predict,
|
37 |
+
inputs=gr.inputs.Image(label="Upload hot dog candidate", type="filepath"),
|
38 |
+
outputs=gr.JSON(),
|
39 |
+
title="Non-Fine-Tuned Model"
|
40 |
+
).launch()
|