Spaces:
Running
Running
Peter Organisciak
commited on
Commit
·
4699c28
1
Parent(s):
4c131cd
turn off example caching
Browse files- gradio-ocsai-d.py +16 -11
gradio-ocsai-d.py
CHANGED
@@ -64,25 +64,32 @@ def classify_image(img_dict: dict):
|
|
64 |
|
65 |
p = get_predictions(img.convert('RGB'))
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
color='red'
|
73 |
).encode(
|
|
|
74 |
y='y'
|
75 |
)
|
76 |
|
77 |
txt = alt.Chart(label_df).mark_text(
|
78 |
align='left',
|
79 |
baseline='middle',
|
80 |
-
dx=
|
|
|
81 |
).encode(
|
82 |
y='y',
|
|
|
83 |
text='text'
|
84 |
)
|
85 |
-
return base_chart +
|
86 |
|
87 |
|
88 |
def update_editor(background, img_editor):
|
@@ -118,10 +125,8 @@ demo = gr.Interface(fn=classify_image,
|
|
118 |
outputs=gr.Plot(),
|
119 |
title="Ocsai-D",
|
120 |
description="Complete the drawing and classify the originality. Choose the brush icon below the image to start editing.\n\nModel from *A Comparison of Supervised and Unsupervised Learning Methods in Automated Scoring of Figural Tests of Creativity* ([preprint](http://dx.doi.org/10.13140/RG.2.2.26865.25444)).\n\nExamples are from MTCI ([Barbot 2018](https://pubmed.ncbi.nlm.nih.gov/30618952/)).",
|
121 |
-
examples=
|
122 |
-
|
123 |
-
label="Prompts"
|
124 |
-
)
|
125 |
)
|
126 |
|
127 |
demo.launch(debug=True)
|
|
|
64 |
|
65 |
p = get_predictions(img.convert('RGB'))
|
66 |
|
67 |
+
label = f"Percentile: {int(p['percentile'])}"
|
68 |
+
label_df = pd.DataFrame({'y': [p['originality']],
|
69 |
+
'x': [p['percentile']],
|
70 |
+
'text': [label]})
|
71 |
+
|
72 |
+
point = alt.Chart(label_df).mark_point(
|
73 |
+
shape='triangle',
|
74 |
+
size=200,
|
75 |
+
filled=True,
|
76 |
color='red'
|
77 |
).encode(
|
78 |
+
x='x',
|
79 |
y='y'
|
80 |
)
|
81 |
|
82 |
txt = alt.Chart(label_df).mark_text(
|
83 |
align='left',
|
84 |
baseline='middle',
|
85 |
+
dx=10, dy=-10,
|
86 |
+
fontSize=14
|
87 |
).encode(
|
88 |
y='y',
|
89 |
+
x='x',
|
90 |
text='text'
|
91 |
)
|
92 |
+
return base_chart + point + txt
|
93 |
|
94 |
|
95 |
def update_editor(background, img_editor):
|
|
|
125 |
outputs=gr.Plot(),
|
126 |
title="Ocsai-D",
|
127 |
description="Complete the drawing and classify the originality. Choose the brush icon below the image to start editing.\n\nModel from *A Comparison of Supervised and Unsupervised Learning Methods in Automated Scoring of Figural Tests of Creativity* ([preprint](http://dx.doi.org/10.13140/RG.2.2.26865.25444)).\n\nExamples are from MTCI ([Barbot 2018](https://pubmed.ncbi.nlm.nih.gov/30618952/)).",
|
128 |
+
examples=examples,
|
129 |
+
cache_examples=False
|
|
|
|
|
130 |
)
|
131 |
|
132 |
demo.launch(debug=True)
|