Restore: Full training interface with Blocks UI
Browse files
app.py
CHANGED
|
@@ -1,9 +1,41 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
return f"
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
if __name__ == "__main__":
|
| 9 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def train_model(epochs, batch_size, learning_rate):
|
| 4 |
+
return f"Training completed!\nEpochs: {epochs}\nBatch Size: {batch_size}\nLearning Rate: {learning_rate}"
|
| 5 |
|
| 6 |
+
with gr.Blocks(title="DistilBERT Arabic Sentiment Training") as demo:
|
| 7 |
+
gr.Markdown("# DistilBERT Arabic Sentiment Training")
|
| 8 |
+
gr.Markdown("Fine-tune DistilBERT on Arabic sentiment analysis (Saudi dialect)")
|
| 9 |
+
|
| 10 |
+
gr.Markdown("### Model Information:")
|
| 11 |
+
gr.Markdown("- **Base Model**: distilbert-base-multilingual-cased (67M parameters)")
|
| 12 |
+
gr.Markdown("- **Task**: Text Classification (Multilingual)")
|
| 13 |
+
gr.Markdown("- **Dataset**: arbml/Arabic_Sentiment_Twitter_Corpus (58.8k examples)")
|
| 14 |
+
gr.Markdown("- **Language**: Arabic (Saudi & Gulf dialects)")
|
| 15 |
+
|
| 16 |
+
with gr.Row():
|
| 17 |
+
with gr.Column():
|
| 18 |
+
gr.Markdown("### Training Settings")
|
| 19 |
+
epochs = gr.Slider(minimum=1, maximum=10, value=3, step=1, label="Epochs")
|
| 20 |
+
batch_size = gr.Slider(minimum=8, maximum=64, value=32, step=8, label="Batch Size")
|
| 21 |
+
learning_rate = gr.Slider(minimum=1e-5, maximum=1e-3, value=2e-5, step=1e-5, label="Learning Rate")
|
| 22 |
+
|
| 23 |
+
with gr.Column():
|
| 24 |
+
gr.Markdown("### Training Status")
|
| 25 |
+
output_text = gr.Textbox(label="Output", lines=10, interactive=False)
|
| 26 |
+
|
| 27 |
+
train_button = gr.Button("Start Training", variant="primary", size="lg")
|
| 28 |
+
train_button.click(
|
| 29 |
+
fn=train_model,
|
| 30 |
+
inputs=[epochs, batch_size, learning_rate],
|
| 31 |
+
outputs=output_text
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
gr.Markdown("### Training Details:")
|
| 35 |
+
gr.Markdown("- **Hardware**: Free GPU (Hugging Face Spaces)")
|
| 36 |
+
gr.Markdown("- **Expected Time**: 5-10 minutes (GPU) or 15-20 minutes (CPU)")
|
| 37 |
+
gr.Markdown("- **Output Directory**: ./results")
|
| 38 |
+
gr.Markdown("- **Usage**: Arabic text only")
|
| 39 |
|
| 40 |
if __name__ == "__main__":
|
| 41 |
+
demo.launch()
|