Spaces:
Sleeping
Sleeping
Commit ·
bac5023
1
Parent(s): 43057db
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,25 @@ def save_image(upload_image_path):
|
|
| 22 |
('Browse', 'Camera'))
|
| 23 |
|
| 24 |
if genre == 'Camera':
|
| 25 |
-
uploaded_image = st.camera_input("Take a picture")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
else:
|
| 27 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 28 |
|
|
|
|
| 22 |
('Browse', 'Camera'))
|
| 23 |
|
| 24 |
if genre == 'Camera':
|
| 25 |
+
#uploaded_image = st.camera_input("Take a picture")
|
| 26 |
+
clear_detect_directory()
|
| 27 |
+
|
| 28 |
+
command = [
|
| 29 |
+
"python",
|
| 30 |
+
"yolov5/detect.py",
|
| 31 |
+
"--weights", "best.pt",
|
| 32 |
+
"--img", "416",
|
| 33 |
+
"--conf", "0.66",
|
| 34 |
+
"--source", upload_image_path
|
| 35 |
+
]
|
| 36 |
+
|
| 37 |
+
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
| 38 |
+
std_out, std_err = process.communicate()
|
| 39 |
+
if process.returncode != 0:
|
| 40 |
+
error_message = f"Error: {std_err}"
|
| 41 |
+
st.text(error_message)
|
| 42 |
+
else:
|
| 43 |
+
st.text(std_out)
|
| 44 |
else:
|
| 45 |
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
|
| 46 |
|