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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -27
app.py CHANGED
@@ -49,32 +49,31 @@ def generate_plant_info(plant_name, language):
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)
 
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
+ )
74
 
75
+ # Custom function to fill the plant name based on example selection
76
+ def fill_plant_name(plant_name, language):
77
+ return plant_name, language
78
 
79
+ demo.launch(share=True)