Spaces:
Sleeping
Sleeping
Update Traffic_Signs_Classification.py
Browse files
Traffic_Signs_Classification.py
CHANGED
@@ -18,11 +18,19 @@ st.title("Speech the Traffic Signs")
|
|
18 |
uploaded_file = st.file_uploader("Choose a PNG image...", type="png", accept_multiple_files=False)
|
19 |
if uploaded_file is not None:
|
20 |
img = Image.open(uploaded_file)
|
|
|
21 |
inputs = processor(img.convert('RGB'), return_tensors="pt")
|
22 |
|
23 |
outputs = model(**inputs)
|
24 |
|
25 |
logits = outputs.logits
|
26 |
img_class_idx=logits.argmax(-1).item()
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
uploaded_file = st.file_uploader("Choose a PNG image...", type="png", accept_multiple_files=False)
|
19 |
if uploaded_file is not None:
|
20 |
img = Image.open(uploaded_file)
|
21 |
+
st.image(img, caption='Uploaded Image.', use_column_width=True)
|
22 |
inputs = processor(img.convert('RGB'), return_tensors="pt")
|
23 |
|
24 |
outputs = model(**inputs)
|
25 |
|
26 |
logits = outputs.logits
|
27 |
img_class_idx=logits.argmax(-1).item()
|
28 |
+
with open("/TrafficSigns_Classification/labels.csv", "r") as file:
|
29 |
+
df = pd.read_csv(file)
|
30 |
+
|
31 |
+
|
32 |
+
num_col = df['ClassId']
|
33 |
+
text_col = df['Name']
|
34 |
+
|
35 |
+
text_value = text_col.loc[num_col == img_class_idx].values[0]
|
36 |
+
st.write("Predicted class:", text_value)
|