Surajnitp commited on
Commit
9217053
·
verified ·
1 Parent(s): 503ce0e

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -80
app.py DELETED
@@ -1,80 +0,0 @@
1
- """
2
-
3
- except subprocess.TimeoutExpired:
4
- return "⏰ Training timed out after 10 minutes."
5
-
6
- except Exception as e:
7
- return f"❌ Unexpected error: {str(e)}"
8
-
9
- # Load the model on startup
10
- load_status = load_model()
11
-
12
- # Create the Gradio interface
13
- with gr.Blocks(
14
- title="Trackmodel - Sentiment Analysis",
15
- theme=gr.themes.Soft(),
16
- css=".gradio-container {max-width: 800px; margin: auto;}"
17
- ) as demo:
18
-
19
- gr.Markdown("""
20
- # 🎯 Trackmodel - Sentiment Analysis
21
-
22
- This Space demonstrates downloading, fine-tuning, and deploying models on Hugging Face.
23
-
24
- **Model:** DistilBERT fine-tuned on IMDb reviews.
25
- """)
26
-
27
- gr.Markdown(f"**Status:** {load_status}")
28
-
29
- with gr.Tab("💬 Predict"):
30
- gr.Markdown("### Enter text to analyze sentiment")
31
-
32
- with gr.Row():
33
- with gr.Column(scale=4):
34
- text_input = gr.Textbox(
35
- label="Your text",
36
- placeholder="Type something like: 'I love this movie!'",
37
- lines=4,
38
- )
39
- with gr.Column(scale=1):
40
- predict_btn = gr.Button("🔮 Predict", variant="primary", size="lg")
41
- clear_btn = gr.Button("🗑️ Clear", variant="secondary")
42
-
43
- output = gr.Markdown(
44
- label="Result",
45
- value="📝 Enter text and click 'Predict' to see results.",
46
- )
47
-
48
- with gr.Tab("⚙️ Training"):
49
- gr.Markdown("""
50
- ### Train the Model on Custom Data
51
-
52
- Click the button below to fine-tune the model on the IMDb dataset.
53
-
54
- ⚠️ **Note:** This will take ~3-5 minutes on a CPU instance.
55
- """)
56
-
57
- with gr.Row():
58
- train_btn = gr.Button("🚀 Start Training", variant="primary", size="lg")
59
-
60
- train_output = gr.Markdown("ℹ️ Click the button to start training.")
61
-
62
- with gr.Tab("ℹ️ About"):
63
- gr.Markdown("""
64
- ## About Trackmodel
65
-
66
- - Downloads DistilBERT
67
- - Fine-tunes on IMDb reviews
68
- - Deploys as a web app
69
-
70
- **Author:** Surajnitp 🚀
71
- """)
72
-
73
- # Connect buttons
74
- predict_btn.click(fn=predict, inputs=text_input, outputs=output)
75
- clear_btn.click(fn=lambda: "", inputs=None, outputs=text_input)
76
- clear_btn.click(fn=lambda: "📝 Enter text and click 'Predict' to see results.", inputs=None, outputs=output)
77
- train_btn.click(fn=run_training, inputs=None, outputs=train_output)
78
-
79
- if __name__ == "__main__":
80
- demo.launch()