Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
]
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
.
|
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 |
-
#
|
102 |
-
|
|
|
|
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()
|