Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,23 +16,38 @@ def predict_image(file, mode):
|
|
| 16 |
keywords = ', '.join(result['suspicious_keywords'])
|
| 17 |
return status, confidence, keywords
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
image_buotton = gr.Button("ιε§εζ")
|
| 33 |
-
image_result =[gr.Textbox(label = "ε€ζ·η΅ζ"),gr.Textbox(label = "ε―ηεζΈ"),gr.Textbox(label = "ε―ηθ©ε½")]
|
| 34 |
-
image_buotton.click(fn=predict_image, inputs=[image_inputs, mode_radio_2], outputs=image_result)
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
demo.launch()
|
|
|
|
| 16 |
keywords = ', '.join(result['suspicious_keywords'])
|
| 17 |
return status, confidence, keywords
|
| 18 |
|
| 19 |
+
text_interface = gr.Interface(
|
| 20 |
+
fn=predict,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.Textbox(label="θΌΈε
₯θ¨ζ―"),
|
| 23 |
+
gr.Radio(choices=["cnn", "bert", "both"], label="εζ樑εΌ", value="cnn")
|
| 24 |
+
],
|
| 25 |
+
outputs=[
|
| 26 |
+
gr.Textbox(label="ε€ζ·η΅ζ"),
|
| 27 |
+
gr.Textbox(label="ε―ηεζΈ"),
|
| 28 |
+
gr.Textbox(label="ε―ηθ©ε½")
|
| 29 |
+
],
|
| 30 |
+
allow_flagging="never"
|
| 31 |
+
)
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
image_interface = gr.Interface(
|
| 34 |
+
fn=predict_image,
|
| 35 |
+
inputs=[
|
| 36 |
+
gr.Image(type="filepath", label="δΈε³εη"),
|
| 37 |
+
gr.Radio(choices=["cnn", "bert", "both"], label="εζ樑εΌ", value="cnn")
|
| 38 |
+
],
|
| 39 |
+
outputs=[
|
| 40 |
+
gr.Textbox(label="ε€ζ·η΅ζ"),
|
| 41 |
+
gr.Textbox(label="ε―ηεζΈ"),
|
| 42 |
+
gr.Textbox(label="ε―ηθ©ε½")
|
| 43 |
+
],
|
| 44 |
+
allow_flagging="never"
|
| 45 |
+
)
|
| 46 |
|
| 47 |
+
# ζ΄εζ Tab δ»ι’
|
| 48 |
+
demo = gr.TabbedInterface(
|
| 49 |
+
interface_list=[text_interface, image_interface],
|
| 50 |
+
tab_names=["ζει ζΈ¬", "εηι ζΈ¬"]
|
| 51 |
+
)
|
| 52 |
|
| 53 |
demo.launch()
|