Spaces:
Sleeping
Sleeping
tonyliu404
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -387,32 +387,33 @@ with col1:
|
|
387 |
st.markdown(f"*Donuts*: 98.11%")
|
388 |
with col2:
|
389 |
st.title('RAG Recipe Result')
|
390 |
-
if not query:
|
391 |
display_response(sample_RAG)
|
392 |
|
393 |
# Image Classification Section
|
394 |
-
if uploaded_image
|
395 |
with col1:
|
396 |
# Open the image
|
397 |
input_image = Image.open(uploaded_image)
|
398 |
|
399 |
# Display the image
|
400 |
st.image(input_image, caption="Uploaded Image.", use_container_width=True)
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
|
|
416 |
|
417 |
# call openai to pick the best classification result based on query
|
418 |
openAICall = [
|
|
|
387 |
st.markdown(f"*Donuts*: 98.11%")
|
388 |
with col2:
|
389 |
st.title('RAG Recipe Result')
|
390 |
+
if not query and not uploaded_image:
|
391 |
display_response(sample_RAG)
|
392 |
|
393 |
# Image Classification Section
|
394 |
+
if uploaded_image:
|
395 |
with col1:
|
396 |
# Open the image
|
397 |
input_image = Image.open(uploaded_image)
|
398 |
|
399 |
# Display the image
|
400 |
st.image(input_image, caption="Uploaded Image.", use_container_width=True)
|
401 |
+
|
402 |
+
if recipe_submit:
|
403 |
+
predictions = classifyImage(input_image)
|
404 |
+
print("Predictions: ", predictions)
|
405 |
+
fpredictions = ""
|
406 |
+
|
407 |
+
# Show the top predictions with percentages
|
408 |
+
st.write("Top Predictions:")
|
409 |
+
for class_name, confidence in predictions:
|
410 |
+
if int(confidence) > 0.05:
|
411 |
+
fpredictions += f"{class_name}: {confidence:.2f}%,"
|
412 |
+
if int(confidence) > 5:
|
413 |
+
class_name = class_name.replace("_", " ")
|
414 |
+
class_name = class_name.title()
|
415 |
+
st.markdown(f"*{class_name}*: {confidence:.2f}%")
|
416 |
+
print(fpredictions)
|
417 |
|
418 |
# call openai to pick the best classification result based on query
|
419 |
openAICall = [
|