Spaces:
Sleeping
Sleeping
translated
Browse files- __pycache__/tools.cpython-311.pyc +0 -0
- app.py +2 -2
- predict.py +8 -5
- requirements.txt +4 -1
__pycache__/tools.cpython-311.pyc
ADDED
|
Binary file (3.56 kB). View file
|
|
|
app.py
CHANGED
|
@@ -20,8 +20,8 @@ from gradio.themes.utils.colors import slate # type: ignore
|
|
| 20 |
|
| 21 |
def render():
|
| 22 |
|
| 23 |
-
title = "
|
| 24 |
-
description = "
|
| 25 |
examples = [
|
| 26 |
'./samples/bulgarian.jpg',
|
| 27 |
'./samples/indian.jpg',
|
|
|
|
| 20 |
|
| 21 |
def render():
|
| 22 |
|
| 23 |
+
title = "Разпознавач на български, индийски и японски шевици"
|
| 24 |
+
description = "Избери снимка на шевица или домъкни една от тези по-долу."
|
| 25 |
examples = [
|
| 26 |
'./samples/bulgarian.jpg',
|
| 27 |
'./samples/indian.jpg',
|
predict.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
'''
|
| 2 |
File: recognize.py
|
| 3 |
-
Project:
|
| 4 |
Author: Milko Videv (milko.videv@thalesgroup.com)
|
| 5 |
-----
|
| 6 |
-
Last Modified: Tuesday, 5th March 2024
|
| 7 |
Modified By: Milko Videv (milko.videv@thalesgroup.com>)
|
| 8 |
-----
|
| 9 |
Copyright 2017 - 2024, Thales DIS, MCS SSH
|
|
@@ -25,15 +25,18 @@ def predict(image):
|
|
| 25 |
pred,pred_idx,probs = learn.predict(img)
|
| 26 |
result = {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
max_type = max(result, key=result.get)
|
| 29 |
-
max_probability = result[max_type] * 100
|
| 30 |
-
print(f"{max_type}
|
| 31 |
|
| 32 |
return result
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|
| 35 |
if debugger_is_active():
|
| 36 |
-
predict("./
|
| 37 |
sys.exit()
|
| 38 |
else:
|
| 39 |
if len(sys.argv) < 2:
|
|
|
|
| 1 |
'''
|
| 2 |
File: recognize.py
|
| 3 |
+
Project: BulgarianPatternsRecognizer
|
| 4 |
Author: Milko Videv (milko.videv@thalesgroup.com)
|
| 5 |
-----
|
| 6 |
+
Last Modified: Tuesday, 5th March 2024 5:51:38 pm
|
| 7 |
Modified By: Milko Videv (milko.videv@thalesgroup.com>)
|
| 8 |
-----
|
| 9 |
Copyright 2017 - 2024, Thales DIS, MCS SSH
|
|
|
|
| 25 |
pred,pred_idx,probs = learn.predict(img)
|
| 26 |
result = {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 27 |
|
| 28 |
+
labels_map = {'bulgarian': 'българска', 'indian': 'индийска', 'japanese': 'японска'}
|
| 29 |
+
result = {labels_map[key]: value for key, value in result.items()}
|
| 30 |
+
|
| 31 |
max_type = max(result, key=result.get)
|
| 32 |
+
max_probability = result[max_type] * 100
|
| 33 |
+
print(f"Тази шевица е {max_type} с вероятност {max_probability:.2f}%")
|
| 34 |
|
| 35 |
return result
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
if debugger_is_active():
|
| 39 |
+
predict("./samples/bulgarian.jpg")
|
| 40 |
sys.exit()
|
| 41 |
else:
|
| 42 |
if len(sys.argv) < 2:
|
requirements.txt
CHANGED
|
@@ -1,2 +1,5 @@
|
|
| 1 |
transformers
|
| 2 |
-
torch
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
transformers
|
| 2 |
+
torch
|
| 3 |
+
fastai
|
| 4 |
+
fastbook
|
| 5 |
+
scikit-image
|