iCoderX commited on
Commit
de4e04d
·
verified ·
1 Parent(s): f3634b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -15
app.py CHANGED
@@ -1,22 +1,42 @@
1
  import gradio as gr
2
- from transformers import pipeline
 
 
3
 
4
- # تحميل نموذج محادثةمكنك تغيير اسم النموذج ليتناسب مع Lingbot-World)
5
- chatbot_pipeline = pipeline("text-generation", model="microsoft/DialoGPT-medium")
6
 
7
- def respond(message, history):
8
- # دمج الرسالة الجديدة مع السياق
9
- response = chatbot_pipeline(message)[0]['generated_text']
10
- return response
 
11
 
12
- # بناء واجهة Gradio
13
- demo = gr.ChatInterface(
14
- fn=respond,
15
- title="Lingbot-World",
16
- description="مرحباً بك في عالم Lingbot-World أونلاين!",
17
- examples=["كيف حالك؟", "ما هو تخصصك؟"],
18
- cache_examples=False,
19
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  if __name__ == "__main__":
22
  demo.launch()
 
1
  import gradio as gr
2
+ import torch
3
+ from diffusers import DiffusionPipeline
4
+ import os
5
 
6
+ # التحقق من وجود GPU (ضروري جداً لهذا النموذج)
7
+ device = "cuda" if torch.cuda.is_available() else "cpu"
8
 
9
+ # تحميل النموذج (استخدمنا الإصدار الأساسي كمثال)
10
+ # ملاحظة: قد يحتاج النموذج لمساحة تخزين كبيرة (أكثر من 10GB)
11
+ model_id = "robbyant/lingbot-world-base-cam"
12
+ pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if device=="cuda" else torch.float32)
13
+ pipe.to(device)
14
 
15
+ def generate_world(input_image, prompt):
16
+ if input_image is None:
17
+ return None
18
+
19
+ # عملية التوليد (Inference)
20
+ # ملاحظة: البارامترات قد تختلف قليلاً حسب التحديث الأخير للنموذج
21
+ output_video = pipe(prompt=prompt, image=input_image, num_frames=16).frames[0]
22
+
23
+ # حفظ الفيديو مؤقتاً لعرضه
24
+ output_path = "output_world.mp4"
25
+ # كود حفظ الفيديو هنا (يعتمد على التنسيق الراجع من النموذج)
26
+ return output_path
27
+
28
+ # بناء الواجهة
29
+ with gr.Blocks() as demo:
30
+ gr.Markdown("# Lingbot-World Online (Genie 3 Alternative)")
31
+ with gr.Row():
32
+ with gr.Column():
33
+ input_img = gr.Image(label="الصورة المرجعية (Initial Frame)")
34
+ prompt_text = gr.Textbox(label="الوصف (Prompt)", placeholder="مثلاً: تحرك الكاميرا لليمين...")
35
+ run_btn = gr.Button("توليد العالم")
36
+ with gr.Column():
37
+ output_vid = gr.Video(label="العالم المتولد")
38
+
39
+ run_btn.click(fn=generate_world, inputs=[input_img, prompt_text], outputs=output_vid)
40
 
41
  if __name__ == "__main__":
42
  demo.launch()