NoufSaleh46 commited on
Commit
7f1d536
·
verified ·
1 Parent(s): e893195

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -50
app.py CHANGED
@@ -49,54 +49,39 @@ def generate_plant_info(plant_name, language):
49
  output = generator(messages)
50
  return output[0]["generated_text"]
51
 
52
- # Create Gradio interface with enhancements
53
- demo = gr.Interface(
54
- fn=generate_plant_info,
55
- inputs=[
56
- gr.Textbox(placeholder="Enter plant name (e.g., Lavender, Aloe Vera)...", label="Plant Name"),
57
- gr.Dropdown(
58
- choices=["English", "Arabic"],
59
- label="Choose Language",
60
- value="English"
61
- )
62
- ],
63
- outputs=gr.Textbox(label="Plant Information"),
64
- title="🌿 AI Plant Guide - English & Arabic 🌿",
65
- description="Enter a plant name, and AI will provide detailed information about it in English or Arabic.",
66
- examples=[
67
- ["Lavender", "English"],
68
- ["اللافندر", "Arabic"],
69
- ["Tulip", "English"],
70
- ["الصبار", "Arabic"]
71
- ],
72
- theme="default",
73
- css="""
74
- body {
75
- font-family: Arial, sans-serif;
76
- background-color: #f9f9f9;
77
- }
78
- .gri-container {
79
- border-radius: 10px;
80
- background-color: #fff;
81
- box-shadow: 0 4px 20px rgba(0,0,0,0.1);
82
- }
83
- .gri-button {
84
- background-color: #4CAF50;
85
- color: white;
86
- }
87
- .gri-button:hover {
88
- background-color: #45a049;
89
- }
90
- .gri-title {
91
- font-size: 24px;
92
- font-weight: bold;
93
- }
94
- .gri-description {
95
- font-size: 16px;
96
- color: #555;
97
- }
98
- """
99
- )
100
 
101
- # Launch the interface
102
- demo.launch(share=True)
 
 
49
  output = generator(messages)
50
  return output[0]["generated_text"]
51
 
52
+ # Create Gradio Blocks interface
53
+ with gr.Blocks(theme="soft") as demo:
54
+ gr.Markdown("<h1 style='text-align: center; color: #2E8B57;'>🌿 AI Plant Guide - English & Arabic 🌿</h1>")
55
+ gr.Markdown("<p style='text-align: center; font-size: 18px;'>Enter a plant name, and AI will provide detailed information about it in English or Arabic.</p>")
56
+
57
+ # Language selection
58
+ language_selector = gr.Radio(["English", "Arabic"], label="🌍 Choose Language", value="English")
59
+
60
+ # Plant name input
61
+ plant_name_input = gr.Textbox(placeholder="Enter plant name (e.g., Lavender, Aloe Vera)...", label="Plant Name")
62
+
63
+ output_text = gr.Textbox(label="Plant Information", interactive=False)
64
+
65
+ # Example button functionality
66
+ example_plants = [
67
+ ("Lavender", "English"),
68
+ ("اللافندر", "Arabic"),
69
+ ("Tulip", "English"),
70
+ ("الصبار", "Arabic"),
71
+ ]
72
+
73
+ with gr.Row():
74
+ for name, lang in example_plants:
75
+ example_button = gr.Button(f"🌿 {name} ({lang})")
76
+
77
+ def fill_plant_name(plant_name=name):
78
+ return plant_name
79
+
80
+ example_button.click(fill_plant_name, outputs=plant_name_input)
81
+
82
+ classify_button = gr.Button("🔍 Get Plant Info", variant="primary")
83
+ classify_button.click(generate_plant_info, inputs=[plant_name_input, language_selector], outputs=output_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
+ # Run the application
86
+ if __name__ == "__main__":
87
+ demo.launch()