taroii commited on
Commit
8c08500
·
1 Parent(s): 35cd13b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
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 query(image):
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, frame
34
 
35
- gr.Interface.load("models/taroii/notfinetuned-detr-50").launch()
 
 
 
 
 
 
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()