File size: 1,120 Bytes
1a1a82f
82aded2
1a1a82f
82aded2
 
1a1a82f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82aded2
 
1a1a82f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from transformers import pipeline
import gradio as gr

# نستخدم نموذج أخف لتوليد النصوص
generator = pipeline("text-generation", model="tiiuae/falcon-rw-1b")

def urban_ai(description):
    prompt = (
        "Design a smart and sustainable urban neighborhood based on this description: "
        + description
        + ". Include building layout, green features, solar energy usage, traffic and pollution reduction, smart lighting, and water-saving techniques. Also estimate energy and resource savings."
    )
    try:
        result = generator(prompt, max_length=300, do_sample=True, temperature=0.7)
        return result[0]['generated_text']
    except Exception as e:
        return f"Error: {str(e)}"

iface = gr.Interface(
    fn=urban_ai,
    inputs=gr.Textbox(lines=4, placeholder="Enter a description of your smart city/neighborhood in English"),
    outputs=gr.Textbox(label="AI Urban Plan & Energy Analysis"),
    title="UrbanAI + AI Energy Optimizer",
    description="Generate smart urban designs and energy optimization analysis using a lightweight AI model."
)

iface.launch()