Spaces:
Build error
Build error
RyanPham19092002
commited on
Commit
·
46ea023
1
Parent(s):
b4559b2
Add application file
Browse files
app.py
CHANGED
@@ -6,17 +6,15 @@ import json
|
|
6 |
import cv2
|
7 |
from PIL import Image
|
8 |
from timeit import default_timer as timer
|
9 |
-
import pathlib
|
10 |
-
import platform
|
11 |
import numpy as np
|
|
|
|
|
12 |
model = torch.hub.load('ultralytics/yolov5','yolov5s', pretrained=True)
|
|
|
13 |
cnt = 0
|
14 |
-
|
15 |
def LCR(bbox,x_img, y_img):
|
16 |
x1 = bbox[0]/x_img
|
17 |
x2 = bbox[2]/x_img
|
18 |
-
|
19 |
-
|
20 |
if x1 < 0.2 and x2 < 0.2 :
|
21 |
location = "Left"
|
22 |
elif x1 > 0.8 and x2 > 0.8:
|
@@ -96,14 +94,6 @@ def turn_img_into_fileJSON(frame):
|
|
96 |
title = "Object-detection"
|
97 |
description = "An EfficientNetB2 feature extractor computer vision model to classify images of object."
|
98 |
article = "Created by Ryan"
|
99 |
-
|
100 |
-
# json_str1, pred_time1 = turn_img_into_fileJSON("C:/Users/ACER/Pictures/mydestiny/273536337_788402492117531_8798195010554693138_n.jpg")
|
101 |
-
# print(json_str1, pred_time1)
|
102 |
-
|
103 |
-
# json_str, pred_time = turn_img_into_fileJSON("D:/cuoc_thi/object-detection/download.jpg")
|
104 |
-
# print(json_str, pred_time)
|
105 |
-
|
106 |
-
|
107 |
# Create the Gradio demo
|
108 |
demo = gr.Interface(fn=turn_img_into_fileJSON, # mapping function from input to output
|
109 |
inputs="pil", # what are the inputs?
|
@@ -116,5 +106,5 @@ demo = gr.Interface(fn=turn_img_into_fileJSON, # mapping function from input to
|
|
116 |
description=description,
|
117 |
article=article,
|
118 |
live = True)
|
119 |
-
|
120 |
-
demo.launch(share=True)
|
|
|
6 |
import cv2
|
7 |
from PIL import Image
|
8 |
from timeit import default_timer as timer
|
|
|
|
|
9 |
import numpy as np
|
10 |
+
from transformers import AutoModel
|
11 |
+
|
12 |
model = torch.hub.load('ultralytics/yolov5','yolov5s', pretrained=True)
|
13 |
+
#model1 = AutoModel.from_pretrained(model)
|
14 |
cnt = 0
|
|
|
15 |
def LCR(bbox,x_img, y_img):
|
16 |
x1 = bbox[0]/x_img
|
17 |
x2 = bbox[2]/x_img
|
|
|
|
|
18 |
if x1 < 0.2 and x2 < 0.2 :
|
19 |
location = "Left"
|
20 |
elif x1 > 0.8 and x2 > 0.8:
|
|
|
94 |
title = "Object-detection"
|
95 |
description = "An EfficientNetB2 feature extractor computer vision model to classify images of object."
|
96 |
article = "Created by Ryan"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
# Create the Gradio demo
|
98 |
demo = gr.Interface(fn=turn_img_into_fileJSON, # mapping function from input to output
|
99 |
inputs="pil", # what are the inputs?
|
|
|
106 |
description=description,
|
107 |
article=article,
|
108 |
live = True)
|
109 |
+
demo.launch()
|
110 |
+
#demo.launch(share=True)
|