Spaces:
Sleeping
Sleeping
tonyliu404
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -410,16 +410,17 @@ if recipe_submit and uploaded_image:
|
|
410 |
fpredictions = ""
|
411 |
class_names = []
|
412 |
confidences = []
|
|
|
413 |
|
414 |
# Show the top predictions with percentages
|
415 |
-
st.write("Top Predictions:")
|
416 |
for class_name, confidence in predictions:
|
417 |
fpredictions += f"{class_name}: {confidence:.2f}%,"
|
418 |
class_name = class_name.replace("_", " ")
|
419 |
class_name = class_name.title()
|
420 |
-
st.markdown(f"*{class_name}*: {confidence:.2f}%")
|
421 |
class_names.append(class_name)
|
422 |
-
confidences.append(confidence)
|
423 |
|
424 |
print(fpredictions)
|
425 |
|
@@ -444,13 +445,14 @@ if recipe_submit and uploaded_image:
|
|
444 |
va='center', ha='right', color='white', fontweight='bold')
|
445 |
|
446 |
ax.set_xticklabels([]) #remove x label
|
447 |
-
|
448 |
-
ax.tick_params(axis='y', colors='white') # Set y label color to white
|
449 |
|
450 |
#no borders
|
451 |
for spine in ax.spines.values():
|
452 |
spine.set_visible(False)
|
453 |
-
|
|
|
|
|
454 |
st.pyplot(fig) # Display the plot in the Streamlit app
|
455 |
|
456 |
# call openai to pick the best classification result based on query
|
|
|
410 |
fpredictions = ""
|
411 |
class_names = []
|
412 |
confidences = []
|
413 |
+
MIN_CONFIDENCE = 5 # 5%
|
414 |
|
415 |
# Show the top predictions with percentages
|
416 |
+
# st.write("Top Predictions:")
|
417 |
for class_name, confidence in predictions:
|
418 |
fpredictions += f"{class_name}: {confidence:.2f}%,"
|
419 |
class_name = class_name.replace("_", " ")
|
420 |
class_name = class_name.title()
|
421 |
+
# st.markdown(f"*{class_name}*: {confidence:.2f}%")
|
422 |
class_names.append(class_name)
|
423 |
+
confidences.append(confidence if confidence > MIN_CONFIDENCE else MIN_CONFIDENCE) #for minimum bar length
|
424 |
|
425 |
print(fpredictions)
|
426 |
|
|
|
445 |
va='center', ha='right', color='white', fontweight='bold')
|
446 |
|
447 |
ax.set_xticklabels([]) #remove x label
|
448 |
+
ax.tick_params(axis='y', colors='white', labelweight='bold')
|
|
|
449 |
|
450 |
#no borders
|
451 |
for spine in ax.spines.values():
|
452 |
spine.set_visible(False)
|
453 |
+
|
454 |
+
x.set_title(class_names[0], color='white', fontsize=16, fontweight='bold', ha='center')
|
455 |
+
|
456 |
st.pyplot(fig) # Display the plot in the Streamlit app
|
457 |
|
458 |
# call openai to pick the best classification result based on query
|