Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- app.py +61 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def process_text(input_text):
|
| 4 |
+
"""تابع ساده برای پردازش متن"""
|
| 5 |
+
return f"پردازش شد: {input_text}"
|
| 6 |
+
|
| 7 |
+
# استفاده از Gradio 6 - هیچ پارامتری در سازنده gr.Blocks() قرار نمیگیرد
|
| 8 |
+
with gr.Blocks() as demo:
|
| 9 |
+
# هدر زیبا با لینک به Anycoder
|
| 10 |
+
gr.Markdown(
|
| 11 |
+
"# 🚀 برنامه پردازش متن\n\n"
|
| 12 |
+
"**ساخته شده با [Anycoder](https://huggingface.co/spaces/akhaliq/anycoder)**"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
with gr.Row():
|
| 16 |
+
with gr.Column():
|
| 17 |
+
# ورودی با طراحی زیبا
|
| 18 |
+
input_component = gr.Textbox(
|
| 19 |
+
label="متن خود را وارد کنید",
|
| 20 |
+
placeholder="اینجا تایپ کنید...",
|
| 21 |
+
lines=3
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
with gr.Column():
|
| 25 |
+
# خروجی با طراحی زیبا
|
| 26 |
+
output_component = gr.Textbox(
|
| 27 |
+
label="نتیجه پردازش",
|
| 28 |
+
interactive=False
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
# دکمه با طراحی مدرن
|
| 32 |
+
process_btn = gr.Button("🔄 پردازش کن", variant="primary")
|
| 33 |
+
|
| 34 |
+
# اضافه کردن مثالهای مفید
|
| 35 |
+
examples = gr.Examples(
|
| 36 |
+
examples=[
|
| 37 |
+
["سلام، چطوری؟"],
|
| 38 |
+
["امروز هوا قشنگه"],
|
| 39 |
+
["برنامهنویسی با پایتون لذت بخشه"],
|
| 40 |
+
inputs=[input_component]
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
# اتصال رویداد با سینتکس Gradio 6
|
| 44 |
+
process_btn.click(
|
| 45 |
+
fn=process_text,
|
| 46 |
+
inputs=[input_component],
|
| 47 |
+
outputs=[output_component],
|
| 48 |
+
api_visibility="public" # Gradio 6 سینتکس
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
# Gradio 6 - تمام پارامترهای برنامه در launch() قرار میگیرند!
|
| 52 |
+
# استفاده از تم Soft برای طراحی مدرن و دوستانه
|
| 53 |
+
demo.launch(
|
| 54 |
+
theme=gr.themes.Soft(
|
| 55 |
+
primary_hue="blue",
|
| 56 |
+
secondary_hue="indigo",
|
| 57 |
+
neutral_hue="slate",
|
| 58 |
+
font=gr.themes.GoogleFont("Vazirmatn"),
|
| 59 |
+
text_size="lg",
|
| 60 |
+
spacing_size="lg",
|
| 61 |
+
)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=6.0
|
| 2 |
+
requests
|
| 3 |
+
Pillow
|