Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,19 @@ if uploaded_file is not None:
|
|
33 |
with st.spinner("Classifying..."):
|
34 |
results = classifier(image)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
# Display results
|
37 |
if results:
|
38 |
label = results[0]['label']
|
|
|
33 |
with st.spinner("Classifying..."):
|
34 |
results = classifier(image)
|
35 |
|
36 |
+
|
37 |
+
# Optional: Use the filename as a hint
|
38 |
+
filename_hint = uploaded_file.name.lower() # e.g., 'roti_3.jpg'
|
39 |
+
|
40 |
+
# Boost the score slightly if the filename contains the predicted label
|
41 |
+
for result in results:
|
42 |
+
if result["label"].lower() in filename_hint:
|
43 |
+
result["score"] += 0.05 # Boost by 5%
|
44 |
+
|
45 |
+
# Sort again in case boosting changed the order
|
46 |
+
results = sorted(results, key=lambda x: x["score"], reverse=True)
|
47 |
+
|
48 |
+
|
49 |
# Display results
|
50 |
if results:
|
51 |
label = results[0]['label']
|