Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,21 @@
|
|
1 |
-
import
|
2 |
from PIL import Image
|
3 |
import cv2
|
4 |
import torch
|
5 |
import numpy as np
|
6 |
|
7 |
-
|
8 |
-
def main():
|
9 |
-
st.title('YOLOv5 detection panneaux de signalisation')
|
10 |
-
image_file = st.file_uploader("choisir une Image", type='png')
|
11 |
-
if image_file is not None:
|
12 |
-
myImage = Image.open(image_file)
|
13 |
-
col1, col2 = st.columns(2)
|
14 |
-
with col1:
|
15 |
-
st.text("Input : ")
|
16 |
-
st.image(myImage)
|
17 |
-
if st.button('Analyse'):
|
18 |
-
new_img=np. array(myImage.convert('RGB' ))
|
19 |
-
img = cv2. cvtColor(new_img,1)
|
20 |
-
results = model(img)
|
21 |
-
with col2:
|
22 |
-
st.text("Output : ")
|
23 |
-
st.image(results.render())
|
24 |
-
|
25 |
if __name__ == '__main__':
|
26 |
model = torch.hub.load('ultralytics/yolov5', 'custom', path='myYOLO/best.pt', force_reload=True)
|
27 |
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
from PIL import Image
|
3 |
import cv2
|
4 |
import torch
|
5 |
import numpy as np
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
if __name__ == '__main__':
|
8 |
model = torch.hub.load('ultralytics/yolov5', 'custom', path='myYOLO/best.pt', force_reload=True)
|
9 |
main()
|
10 |
+
|
11 |
+
demo_app = gr.Interface(
|
12 |
+
fn=yolov5_inference,
|
13 |
+
inputs=inputs,
|
14 |
+
outputs=outputs,
|
15 |
+
title=title,
|
16 |
+
examples=examples,
|
17 |
+
cache_examples=True,
|
18 |
+
live=True,
|
19 |
+
theme='huggingface',
|
20 |
+
)
|
21 |
+
demo_app.launch(debug=True, enable_queue=True)
|