Guy2 commited on
Commit
134848b
·
1 Parent(s): e401490

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,12 +3,13 @@ from transformers import DetrImageProcessor, DetrForObjectDetection
3
  import torch
4
  import supervision as sv
5
  import json
 
6
 
7
  image_processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
8
  model = DetrForObjectDetection.from_pretrained("Guy2/AirportSec-150epoch")
9
  id2label = {0: 'dangerous-items', 1: 'Gun', 2: 'Knife', 3: 'Pliers', 4: 'Scissors', 5: 'Wrench'}
10
- def anylize(img):
11
- image = img
12
 
13
  with torch.no_grad():
14
 
@@ -28,4 +29,4 @@ def anylize(img):
28
  json_list = json.dumps(labels)
29
  return json_list
30
 
31
- gr.Interface(fn = anylize, inputs="image", outputs=gr.JSON()).launch()
 
3
  import torch
4
  import supervision as sv
5
  import json
6
+ import requests
7
 
8
  image_processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
9
  model = DetrForObjectDetection.from_pretrained("Guy2/AirportSec-150epoch")
10
  id2label = {0: 'dangerous-items', 1: 'Gun', 2: 'Knife', 3: 'Pliers', 4: 'Scissors', 5: 'Wrench'}
11
+ def anylize(url):
12
+ image = Image.open(requests.get(url, stream=True).raw)
13
 
14
  with torch.no_grad():
15
 
 
29
  json_list = json.dumps(labels)
30
  return json_list
31
 
32
+ gr.Interface(fn = anylize, inputs="text", outputs=gr.JSON()).launch()