tonyliu404 commited on
Commit
f20f9cb
·
verified ·
1 Parent(s): 911f461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -17
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 and recipe_submit:
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
- predictions = classifyImage(input_image)
403
- print("Predictions: ", predictions)
404
- fpredictions = ""
405
-
406
- # Show the top predictions with percentages
407
- st.write("Top Predictions:")
408
- for class_name, confidence in predictions:
409
- if int(confidence) > 0.05:
410
- fpredictions += f"{class_name}: {confidence:.2f}%,"
411
- if int(confidence) > 5:
412
- class_name = class_name.replace("_", " ")
413
- class_name = class_name.title()
414
- st.markdown(f"*{class_name}*: {confidence:.2f}%")
415
- print(fpredictions)
 
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 = [