Adam36 commited on
Commit
3acb8e4
·
verified ·
1 Parent(s): 6b127d6

Create zombie-ai-video

Browse files
Files changed (1) hide show
  1. zombie-ai-video +38 -0
zombie-ai-video ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ API_URL = "https://api-inference.huggingface.co/models/fofr/moonvalley"
5
+ headers = {
6
+ "Authorization": f"Bearer hf_your_token_goes_here"
7
+ }
8
+
9
+ def generate_video(prompt):
10
+ payload = {"inputs": prompt}
11
+ response = requests.post(API_URL, headers=headers, json=payload)
12
+
13
+ try:
14
+ result = response.json()
15
+ except:
16
+ return "Error: Failed to decode server response"
17
+
18
+ if isinstance(result, dict) and "error" in result:
19
+ return f"Error: {result['error']}"
20
+
21
+ video_url = result.get("video") or result.get("url") or (
22
+ result[0].get("url") if isinstance(result, list) and isinstance(result[0], dict) else None
23
+ )
24
+
25
+ if not video_url:
26
+ return "No video returned. Try another prompt."
27
+
28
+ return video_url
29
+
30
+ iface = gr.Interface(
31
+ fn=generate_video,
32
+ inputs=gr.Textbox(lines=3, placeholder="Enter your horror or zombie video prompt here..."),
33
+ outputs="video",
34
+ title="Zombie Horror Generator",
35
+ description="Create short horror videos from text prompts using the Moonvalley model."
36
+ )
37
+
38
+ iface.launch()