hananbahtiti commited on
Commit
3d1e9a0
1 Parent(s): bdfdf3a

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -6
main.py CHANGED
@@ -45,13 +45,26 @@ async def classify_image(file: UploadFile):
45
 
46
  return JSONResponse(content={"predicted_class": predicted_class_name})
47
 
48
-
49
- st.title("تصنيف الصور باستخدام Streamlit")
50
 
51
- uploaded_file = st.file_uploader("رفع صورة", type=["jpg", "jpeg", "png"])
 
 
 
 
 
 
52
 
53
  if uploaded_file is not None:
 
54
  image = Image.open(uploaded_file)
55
- st.image(image, caption='الصورة التي تم رفعها.', use_column_width=True)
56
- st.write("")
57
- st.write("تم تصنيف الصورة كـ", classify_image(image))
 
 
 
 
 
 
 
 
 
45
 
46
  return JSONResponse(content={"predicted_class": predicted_class_name})
47
 
 
 
48
 
49
+
50
+
51
+ # Streamlit UI
52
+ st.title("Binary Image Classification")
53
+ st.write("Upload an image to classify if it's a flower or not.")
54
+
55
+ uploaded_file = st.file_uploader("Choose an image...", type="jpg")
56
 
57
  if uploaded_file is not None:
58
+ # Display uploaded image
59
  image = Image.open(uploaded_file)
60
+ st.image(image, caption="Uploaded Image.", use_column_width=True)
61
+
62
+ # Send the image to FastAPI for classification
63
+ url = "http://127.0.0.1:7860/classify/" # Replace with your FastAPI server URL
64
+ # Replace with your FastAPI server URL
65
+ files = {"file": uploaded_file}
66
+ response = requests.post(url, files=files)
67
+
68
+ if response.status_code == 200:
69
+ result = response.json()
70
+ st.write("Predicted Class:", result["predicted_class"])