NoufSaleh46 commited on
Commit
cd317ec
·
verified ·
1 Parent(s): 098248b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -42
app.py CHANGED
@@ -49,48 +49,32 @@ 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
- custom_css = """
54
- body {
55
- font-family: Arial, sans-serif;
56
- background-color: #f9f9f9;
57
- }
58
- .gri-container {
59
- border-radius: 10px;
60
- background-color: #fff;
61
- box-shadow: 0 4px 20px rgba(0,0,0,0.1);
62
- }
63
- .gri-button {
64
- background-color: #4CAF50;
65
- color: white;
66
- }
67
- .gri-button:hover {
68
- background-color: #45a049;
69
- }
70
- """
71
 
72
- demo = gr.Interface(
73
- fn=generate_plant_info,
74
- inputs=[
75
- gr.Textbox(placeholder="Enter plant name (e.g., Lavender, Aloe Vera)...", label="Plant Name"),
76
- gr.Dropdown(
77
- choices=["English", "Arabic"],
78
- label="Choose Language",
79
- value="English"
80
- )
81
- ],
82
- outputs=gr.Textbox(label="Plant Information"),
83
- title="🌿 AI Plant Guide - English & Arabic 🌿",
84
- description="Enter a plant name, and AI will provide detailed information about it in English or Arabic.",
85
- examples=[
86
- ["Lavender", "English"],
87
- ["اللافندر", "Arabic"],
88
- ["Tulip", "English"],
89
- ["الصبار", "Arabic"]
90
- ],
91
- theme="default",
92
- css=custom_css, # Add custom CSS here
93
- )
94
 
95
- demo.launch(share=True) # Launch the interface without css parameter
 
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  output = generator(messages)
50
  return output[0]["generated_text"]
51
 
52
+ # Create Gradio interface with green theme
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_selector = gr.Radio(["English", "Arabic"], label="🌍 Choose Language", value="English")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ plant_name_input = gr.Textbox(placeholder="Enter plant name (e.g., Lavender, Aloe Vera)...", label="📋 Plant Name")
60
+ output_text = gr.Textbox(label="🔍 Plant Information", interactive=False)
61
 
62
+ classify_button = gr.Button("🔍 Get Plant Info", variant="primary", elem_id="classify_button")
63
+
64
+ classify_button.click(generate_plant_info, inputs=[plant_name_input, language_selector], outputs=output_text)
65
+
66
+ gr.Markdown("<h2 style='text-align: center;'>🌼 Try Examples 🌼</h2>")
67
+ example_plants = [("Lavender", "English"), ("اللافندر", "Arabic"), ("Tulip", "English"), ("الصبار", "Arabic")]
68
+
69
+ with gr.Row():
70
+ for plant, lang in example_plants:
71
+ example_button = gr.Button(f"🌿 {plant}", variant="primary", elem_id="example_button")
72
+
73
+ def process_example(plant=plant, lang=lang):
74
+ return generate_plant_info(plant, lang)
75
+
76
+ example_button.click(process_example, inputs=[], outputs=output_text)
77
+
78
+ # Run the application
79
+ if __name__ == "__main__":
80
+ demo.launch(share=True)