Spaces:
Runtime error
Runtime error
Download app.py from Peter10355/twitter: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/Peter10355/twitter/resolve/main/app.py
- Command line
-
hf download hf://spaces/Peter10355/twitter/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Peter10355/twitter/resolve/main/app.py
1.2 kB
| import numpy as np | |
| import random | |
| import gradio as gr | |
| def predict(text, method): | |
| text = random.uniform(0, 1) | |
| pre = [text, 1 - text] | |
| if method == "Naive Bayes": | |
| out = {"Positive": round(pre[0], 2), "Negative": round(pre[1], 2)} | |
| elif method == "Decision Tree": | |
| out = {"Positive": round(pre[0], 2), "negative": round(pre[1], 2)} | |
| elif method == "Random Tree": | |
| out = {"Positive": round(pre[0], 2), "negative": round(pre[1], 2)} | |
| elif method == "CNN": | |
| out = {"Positive": round(pre[0], 2), "Negative": round(pre[1], 2)} | |
| return out | |
| with gr.Blocks() as demo: | |
| with gr.Tab("!!!"): | |
| image_path = "NTPU.webp" | |
| gr.Image(image_path,label="NTPU Bear",height=800,width=800) | |
| with gr.Tab("Let's Analysis!!!"): | |
| with gr.Column(): | |
| text =gr.Textbox(label="Text",placeholder="Ex: I'm happyyyy!") | |
| method=gr.Radio(label="Choose the Model", choices=["Naive Bayes", "Decision Tree","Random Tree","CNN"]) | |
| text_button = gr.Button("Run") | |
| with gr.Column(): | |
| output= gr.Label(label="Output") | |
| text_button.click(predict ,[text,method], [ output]) | |
| demo.launch(True) | |