Dxulz's picture
Update app.py
82aded2 verified
Raw History Blame Contribute Delete
1.12 kB
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()