Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -410,8 +410,7 @@ if recipe_submit and uploaded_image:
|
|
| 410 |
fpredictions = ""
|
| 411 |
class_names = []
|
| 412 |
confidences = []
|
| 413 |
-
|
| 414 |
-
|
| 415 |
# Show the top predictions with percentages
|
| 416 |
st.write("Top Predictions:")
|
| 417 |
for class_name, confidence in predictions:
|
|
@@ -420,7 +419,7 @@ if recipe_submit and uploaded_image:
|
|
| 420 |
class_name = class_name.title()
|
| 421 |
st.markdown(f"*{class_name}*: {confidence:.2f}%")
|
| 422 |
class_names.append(class_name)
|
| 423 |
-
confidences.append(confidence
|
| 424 |
|
| 425 |
print(fpredictions)
|
| 426 |
|
|
@@ -435,7 +434,8 @@ if recipe_submit and uploaded_image:
|
|
| 435 |
fig, ax = plt.subplots(figsize=(8, 6))
|
| 436 |
bars = ax.barh(class_names, confidences, color=cmap(norm(confidences)))
|
| 437 |
|
| 438 |
-
fig.patch.set_alpha(0
|
|
|
|
| 439 |
|
| 440 |
# Add labels inside the bars, aligned to the right
|
| 441 |
for bar in bars:
|
|
@@ -444,7 +444,9 @@ 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 |
#no borders
|
| 449 |
for spine in ax.spines.values():
|
| 450 |
spine.set_visible(False)
|
|
|
|
| 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:
|
|
|
|
| 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 |
|
|
|
|
| 434 |
fig, ax = plt.subplots(figsize=(8, 6))
|
| 435 |
bars = ax.barh(class_names, confidences, color=cmap(norm(confidences)))
|
| 436 |
|
| 437 |
+
fig.patch.set_alpha(0) # Transparent background
|
| 438 |
+
ax.set_facecolor('none')
|
| 439 |
|
| 440 |
# Add labels inside the bars, aligned to the right
|
| 441 |
for bar in bars:
|
|
|
|
| 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)
|