Spaces:
Runtime error
Runtime error
Create App.py
Browse files
App.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
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()
|