MilkoTv commited on
Commit
6b42630
·
1 Parent(s): e77e2e7

removed submit and added link for images

Browse files
Files changed (4) hide show
  1. __pycache__/predict.cpython-311.pyc +0 -0
  2. app.py +10 -13
  3. predict.py +3 -1
  4. requirements.txt +0 -2
__pycache__/predict.cpython-311.pyc ADDED
Binary file (2.98 kB). View file
 
app.py CHANGED
@@ -1,9 +1,9 @@
1
  '''
2
  File: recognize.py
3
- Project: PatternsRecognizer
4
  Author: Milko Videv (milko.videv@thalesgroup.com)
5
  -----
6
- Last Modified: Monday, 4th March 2024 9:38:39 am
7
  Modified By: Milko Videv (milko.videv@thalesgroup.com>)
8
  -----
9
  Copyright 2017 - 2024, Thales DIS, MCS SSH
@@ -21,27 +21,24 @@ from gradio.themes.utils.colors import slate # type: ignore
21
  def render():
22
 
23
  title = "Разпознавач на български, индийски и японски шевици"
24
- description = "Избери снимка на шевица или домъкни една от тези по-долу."
 
25
  examples = [
26
  './samples/bulgarian.jpg',
27
  './samples/indian.jpg',
28
  './samples/japanese.jpg'
29
- ]
30
- rand_examples = [
31
- pick_random_file("./patterns/bulgarian"),
32
- pick_random_file("./patterns/indian"),
33
- pick_random_file("./patterns/japanese"),
34
- ]
35
 
36
  demo = gr.Interface(fn=predict,
37
  theme=gr.themes.Monochrome(primary_hue=slate),
38
- inputs=gr.components.Image(shape=(512, 512), interactive=True),
39
- outputs=gr.components.Label(num_top_classes=3),
40
  title=title,
41
  description=description,
 
42
  examples=examples,
43
- allow_flagging="manual",
44
- flagging_options=["Correct", "Incorrect"],
45
  css=
46
  "#component-3 { background-color: rgb(192, 192, 192) !important; }"
47
  "#component-3 H1 { margin: 1.5rem 0 1.5rem 0; color: #252873; !important;}"
 
1
  '''
2
  File: recognize.py
3
+ Project: BulgarianPatternsRecognizer
4
  Author: Milko Videv (milko.videv@thalesgroup.com)
5
  -----
6
+ Last Modified: Tuesday, 5th March 2024 6:28:12 pm
7
  Modified By: Milko Videv (milko.videv@thalesgroup.com>)
8
  -----
9
  Copyright 2017 - 2024, Thales DIS, MCS SSH
 
21
  def render():
22
 
23
  title = "Разпознавач на български, индийски и японски шевици"
24
+ description = "Заредете снимка на шевица от 'Снимки за тестване' по-долу или домъкнете една от 3-те примерни"
25
+ article = "<a href='https://www.google.com/search?q=bulgarian+patterns+images'>Снимки за тестване"
26
  examples = [
27
  './samples/bulgarian.jpg',
28
  './samples/indian.jpg',
29
  './samples/japanese.jpg'
30
+ ]
 
 
 
 
 
31
 
32
  demo = gr.Interface(fn=predict,
33
  theme=gr.themes.Monochrome(primary_hue=slate),
34
+ inputs=gr.components.Image(shape=(512, 512), interactive=True, label="Шевица"),
35
+ outputs=gr.components.Label(num_top_classes=3, label="Резултат"),
36
  title=title,
37
  description=description,
38
+ article=article,
39
  examples=examples,
40
+ allow_flagging="never",
41
+ live=True,
42
  css=
43
  "#component-3 { background-color: rgb(192, 192, 192) !important; }"
44
  "#component-3 H1 { margin: 1.5rem 0 1.5rem 0; color: #252873; !important;}"
predict.py CHANGED
@@ -3,7 +3,7 @@ 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
@@ -21,6 +21,8 @@ learn = load_learner("./models/trained.pkl")
21
  labels = learn.dls.vocab
22
 
23
  def predict(image):
 
 
24
  img = PILImage.create(image)
25
  pred,pred_idx,probs = learn.predict(img)
26
  result = {labels[i]: float(probs[i]) for i in range(len(labels))}
 
3
  Project: BulgarianPatternsRecognizer
4
  Author: Milko Videv (milko.videv@thalesgroup.com)
5
  -----
6
+ Last Modified: Tuesday, 5th March 2024 6:29:44 pm
7
  Modified By: Milko Videv (milko.videv@thalesgroup.com>)
8
  -----
9
  Copyright 2017 - 2024, Thales DIS, MCS SSH
 
21
  labels = learn.dls.vocab
22
 
23
  def predict(image):
24
+ if image is None:
25
+ return None
26
  img = PILImage.create(image)
27
  pred,pred_idx,probs = learn.predict(img)
28
  result = {labels[i]: float(probs[i]) for i in range(len(labels))}
requirements.txt CHANGED
@@ -1,5 +1,3 @@
1
- transformers
2
- torch
3
  fastai
4
  fastbook
5
  scikit-image
 
 
 
1
  fastai
2
  fastbook
3
  scikit-image