Files changed (1) hide show
  1. App.py +351 -0
App.py ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ results.txt story_app.py ~ $ nano story_app.py
2
+ ~ $ cat story_app.py import requests
3
+ import os
4
+ # 1. SETUP - Replace 'YOUR_TOKEN_HERE' with your real Hugging Face token
5
+ API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
6
+ headers = {"Authorization": "Bearer YOUR_TOKEN_HERE"}
7
+ def generate_video_from_story():
8
+ # 2. THE STORY INPUT
9
+ print("\n--- StoryViz AI ---")
10
+ story = input("Enter your story: ") print("🎨 AI is drawing your story... please wait.")
11
+ # 3. GENERATE THE IMAGE
12
+ response = requests.post(API_URL, headers=headers, json={"inputs": story})
13
+
14
+ if response.status_code == 200:
15
+ with open("scene.jpg", "wb") as f:
16
+ f.write(response.content)
17
+ print("βœ… Image generated!")
18
+
19
+ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
20
+ print("🎬 Converting image to a 5-second video...")
21
+ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
22
+
23
+ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
24
+ else:
25
+ print(f"❌ Error: {response.status_code}. Check your Token!")
26
+
27
+ if __name__ == "__main__":
28
+ generate_video_from_story()
29
+
30
+ tus_code == 200:
31
+ with open("scene.jpg", "wb") as f:
32
+ f.write(response.content)
33
+ print("βœ… Image generated!")
34
+
35
+ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
36
+ print("🎬 Converting image to a 5-second video...")
37
+ # This command takes the image and loops it for 5 seconds
38
+ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
39
+
40
+ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
41
+ print("To view it, move it to your phone storage using:")
42
+ print("termux-setup-storage && cp story_video.mp4 /sdcard/")
43
+ else:
44
+ print("❌ Error: AI is busy or Token is wrong.")
45
+
46
+ generate_video_from_story()
47
+ The program import is not installed. Install it by executing:
48
+ pkg install imagemagick
49
+ ~ $ import os
50
+ The program import is not installed. Install it by executing:
51
+ pkg install imagemagick
52
+ ~ $ import time
53
+ The program import is not installed. Install it by executing:
54
+ pkg install imagemagick
55
+ ~ $
56
+ ~ $ # 1. SETUP
57
+ ~ $ API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
58
+ API_URL: command not found
59
+ ~ $ headers = {"Authorization": "Bearer YOUR_TOKEN_HERE"}
60
+ No command headers found, did you mean:
61
+ Command feathers in package chicken
62
+ Command head in package coreutils
63
+ Command heimer in package heimer from the x11-repo repository
64
+ Command hexer in package hexer
65
+ Command readelf in package llvm
66
+ Command folders in package mailutils
67
+ Command gears in package mesa-demos from the x11-repo repository
68
+ Command folders in package nmh
69
+ Command sneakers in package no-more-secrets
70
+ ~ $
71
+ ~ $ def generate_video_from_story():
72
+ bash: syntax error near unexpected token `('
73
+ ~ $ # 2. THE STORY INPUT
74
+ ~ $ story = input("Enter your story: ")
75
+ bash: syntax error near unexpected token `('
76
+ ~ $ print("🎨 AI is drawing your story...")
77
+ bash: syntax error near unexpected token `"🎨 AI is drawing your story..."'
78
+ ~ $
79
+ ~ $ # 3. GENERATE THE IMAGE
80
+ ~ $ response = requests.post(API_URL, headers=headers, json={"inputs": story})
81
+ bash: syntax error near unexpected token `('
82
+ ~ $
83
+ ~ $ if response.status_code == 200:
84
+ > with open("scene.jpg", "wb") as f:
85
+ bash: syntax error near unexpected token `('
86
+ ~ $ f.write(response.content)
87
+ bash: syntax error near unexpected token `response.content'
88
+ ~ $ print("βœ… Image generated!")
89
+ bash: syntax error near unexpected token `"βœ… Image generated!"'
90
+ ~ $
91
+ ~ $ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
92
+ ~ $ print("🎬 Converting image to a 5-second video...")
93
+ bash: syntax error near unexpected token `"🎬 Converting image to a 5-second video..."'
94
+ ~ $ # This command takes the image and loops it for 5 seconds
95
+ ~ $ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
96
+ bash: syntax error near unexpected token `"ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y"'
97
+ ~ $
98
+ ~ $ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
99
+ bash: syntax error near unexpected token `"\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4"'
100
+ ~ $ print("To view it, move it to your phone storage using:")
101
+ bash: syntax error near unexpected token `"To view it, move it to your phone storage using:"'
102
+ ~ $ print("termux-setup-storage && cp story_video.mp4 /sdcard/")
103
+ bash: syntax error near unexpected token `"termux-setup-storage && cp story_video.mp4 /sdcard/"'
104
+ ~ $ else:
105
+ No command else: found, did you mean:
106
+ Command plser in package libgnustep-base
107
+ ~ $ print("❌ Error: AI is busy or Token is wrong.")
108
+ bash: syntax error near unexpected token `"❌ Error: AI is busy or Token is wrong."'
109
+ ~ $
110
+ ~ $ generate_video_from_story()import requests
111
+ import os
112
+ import time
113
+
114
+ # 1. SETUP
115
+ API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
116
+ headers = {"Authorization": "Bearer YOUR_TOKEN_HERE"}
117
+
118
+ def generate_video_from_story():
119
+ # 2. THE STORY INPUT
120
+ story = input("Enter your story: ")
121
+ print("🎨 AI is drawing your story...")
122
+
123
+ # 3. GENERATE THE IMAGE
124
+ response = requests.post(API_URL, headers=headers, json={"inputs": story})
125
+
126
+ if response.status_code == 200:
127
+ with open("scene.jpg", "wb") as f:
128
+ f.write(response.content)
129
+ print("βœ… Image generated!")
130
+
131
+ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
132
+ print("🎬 Converting image to a 5-second video...")
133
+ # This command takes the image and loops it for 5 seconds
134
+ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
135
+
136
+ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
137
+ print("To view it, move it to your phone storage using:")
138
+ print("termux-setup-storage && cp story_video.mp4 /sdcard/")
139
+ else:
140
+ print("❌ Error: AI is busy or Token is wrong.")
141
+
142
+ generate_video_from_story()
143
+ import os
144
+ from openai import OpenAI
145
+
146
+ client = OpenAI(
147
+ base_url="https://router.huggingface.co/v1",
148
+ api_key=os.environ["HF_TOKEN"],
149
+ )
150
+
151
+ completion = client.chat.completions.create(
152
+ model="moonshotai/Kimi-K2-Instruct-0905",
153
+ messages=[
154
+ {
155
+ "role": "user",
156
+ "content": "Generate a list of 10 interesting facts about space."
157
+ }
158
+ ],
159
+ )
160
+
161
+ print(completion.choices[0].message)import os
162
+ from huggingface_hub import InferenceClient
163
+
164
+ client = InferenceClient(
165
+ provider="wavespeed",
166
+ api_key=os.environ["HF_TOKEN"],
167
+ )
168
+
169
+ # output is a PIL.Image object
170
+ image = client.text_to_image(
171
+ "A robot playing chess with a human",
172
+ model="black-forest-labs/FLUX.1-dev",
173
+ )
174
+
175
+ ~ $ cat story_app.py
176
+ import requests
177
+ import os
178
+
179
+ # 1. SETUP - Replace 'YOUR_TOKEN_HERE' with your real Hugging Face token
180
+ API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
181
+ headers = {"Authorization": "Bearer YOUR_TOKEN_HERE"}
182
+
183
+ def generate_video_from_story():
184
+ # 2. THE STORY INPUT
185
+ print("\n--- StoryViz AI ---")
186
+ story = input("Enter your story: ")
187
+ print("🎨 AI is drawing your story... please wait.")
188
+
189
+ # 3. GENERATE THE IMAGE
190
+ response = requests.post(API_URL, headers=headers, json={"inputs": story})
191
+
192
+ if response.status_code == 200:
193
+ with open("scene.jpg", "wb") as f:
194
+ f.write(response.content)
195
+ print("βœ… Image generated!")
196
+
197
+ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
198
+ print("🎬 Converting image to a 5-second video...")
199
+ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
200
+
201
+ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
202
+ else:
203
+ print(f"❌ Error: {response.status_code}. Check your Token!")
204
+
205
+ if __name__ == "__main__":
206
+ generate_video_from_story()
207
+
208
+ tus_code == 200:
209
+ with open("scene.jpg", "wb") as f:
210
+ f.write(response.content)
211
+ print("βœ… Image generated!")
212
+
213
+ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
214
+ print("🎬 Converting image to a 5-second video...")
215
+ # This command takes the image and loops it for 5 seconds
216
+ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
217
+
218
+ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
219
+ print("To view it, move it to your phone storage using:")
220
+ print("termux-setup-storage && cp story_video.mp4 /sdcard/")
221
+ else:
222
+ print("❌ Error: AI is busy or Token is wrong.")
223
+
224
+ generate_video_from_story()
225
+ The program import is not installed. Install it by executing:
226
+ pkg install imagemagick
227
+ ~ $ import os
228
+ The program import is not installed. Install it by executing:
229
+ pkg install imagemagick
230
+ ~ $ import time
231
+ The program import is not installed. Install it by executing:
232
+ pkg install imagemagick
233
+ ~ $
234
+ ~ $ # 1. SETUP
235
+ ~ $ API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
236
+ API_URL: command not found
237
+ ~ $ headers = {"Authorization": "Bearer YOUR_TOKEN_HERE"}
238
+ No command headers found, did you mean:
239
+ Command feathers in package chicken
240
+ Command head in package coreutils
241
+ Command heimer in package heimer from the x11-repo repository
242
+ Command hexer in package hexer
243
+ Command readelf in package llvm
244
+ Command folders in package mailutils
245
+ Command gears in package mesa-demos from the x11-repo repository
246
+ Command folders in package nmh
247
+ Command sneakers in package no-more-secrets
248
+ ~ $
249
+ ~ $ def generate_video_from_story():
250
+ bash: syntax error near unexpected token `('
251
+ ~ $ # 2. THE STORY INPUT
252
+ ~ $ story = input("Enter your story: ")
253
+ bash: syntax error near unexpected token `('
254
+ ~ $ print("🎨 AI is drawing your story...")
255
+ bash: syntax error near unexpected token `"🎨 AI is drawing your story..."'
256
+ ~ $
257
+ ~ $ # 3. GENERATE THE IMAGE
258
+ ~ $ response = requests.post(API_URL, headers=headers, json={"inputs": story})
259
+ bash: syntax error near unexpected token `('
260
+ ~ $
261
+ ~ $ if response.status_code == 200:
262
+ > with open("scene.jpg", "wb") as f:
263
+ bash: syntax error near unexpected token `('
264
+ ~ $ f.write(response.content)
265
+ bash: syntax error near unexpected token `response.content'
266
+ ~ $ print("βœ… Image generated!")
267
+ bash: syntax error near unexpected token `"βœ… Image generated!"'
268
+ ~ $
269
+ ~ $ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
270
+ ~ $ print("🎬 Converting image to a 5-second video...")
271
+ bash: syntax error near unexpected token `"🎬 Converting image to a 5-second video..."'
272
+ ~ $ # This command takes the image and loops it for 5 seconds
273
+ ~ $ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
274
+ bash: syntax error near unexpected token `"ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y"'
275
+ ~ $
276
+ ~ $ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
277
+ bash: syntax error near unexpected token `"\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4"'
278
+ ~ $ print("To view it, move it to your phone storage using:")
279
+ bash: syntax error near unexpected token `"To view it, move it to your phone storage using:"'
280
+ ~ $ print("termux-setup-storage && cp story_video.mp4 /sdcard/")
281
+ bash: syntax error near unexpected token `"termux-setup-storage && cp story_video.mp4 /sdcard/"'
282
+ ~ $ else:
283
+ No command else: found, did you mean:
284
+ Command plser in package libgnustep-base
285
+ ~ $ print("❌ Error: AI is busy or Token is wrong.")
286
+ bash: syntax error near unexpected token `"❌ Error: AI is busy or Token is wrong."'
287
+ ~ $
288
+ ~ $ generate_video_from_story()import requests
289
+ import os
290
+ import time
291
+
292
+ # 1. SETUP
293
+ API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
294
+ headers = {"Authorization": "Bearer YOUR_TOKEN_HERE"}
295
+
296
+ def generate_video_from_story():
297
+ # 2. THE STORY INPUT
298
+ story = input("Enter your story: ")
299
+ print("🎨 AI is drawing your story...")
300
+
301
+ # 3. GENERATE THE IMAGE
302
+ response = requests.post(API_URL, headers=headers, json={"inputs": story})
303
+
304
+ if response.status_code == 200:
305
+ with open("scene.jpg", "wb") as f:
306
+ f.write(response.content)
307
+ print("βœ… Image generated!")
308
+
309
+ # 4. TURN IMAGE INTO VIDEO (Using ffmpeg)
310
+ print("🎬 Converting image to a 5-second video...")
311
+ # This command takes the image and loops it for 5 seconds
312
+ os.system("ffmpeg -loop 1 -i scene.jpg -c:v libx264 -t 5 -pix_fmt yuv420p story_video.mp4 -y")
313
+
314
+ print("\nπŸš€ SUCCESS! Your video is saved as: story_video.mp4")
315
+ print("To view it, move it to your phone storage using:")
316
+ print("termux-setup-storage && cp story_video.mp4 /sdcard/")
317
+ else:
318
+ print("❌ Error: AI is busy or Token is wrong.")
319
+
320
+ generate_video_from_story()
321
+ import os
322
+ from openai import OpenAI
323
+
324
+ client = OpenAI(
325
+ base_url="https://router.huggingface.co/v1",
326
+ api_key=os.environ["HF_TOKEN"],
327
+ )
328
+
329
+ completion = client.chat.completions.create(
330
+ model="moonshotai/Kimi-K2-Instruct-0905",
331
+ messages=[
332
+ {
333
+ "role": "user",
334
+ "content": "Generate a list of 10 interesting facts about space."
335
+ }
336
+ ],
337
+ )
338
+
339
+ print(completion.choices[0].message)import os
340
+ from huggingface_hub import InferenceClient
341
+
342
+ client = InferenceClient(
343
+ provider="wavespeed",
344
+ api_key=os.environ["HF_TOKEN"],
345
+ )
346
+
347
+ # output is a PIL.Image object
348
+ image = client.text_to_image(
349
+ "A robot playing chess with a human",
350
+ model="black-forest-labs/FLUX.1-dev",
351
+ )