cakemus commited on
Commit
5dc1a58
·
1 Parent(s): 183aac1

kandinskytest

Browse files
Files changed (2) hide show
  1. app.py +12 -12
  2. requirements.txt +3 -1
app.py CHANGED
@@ -1,24 +1,24 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
  from spaces import GPU # Import the GPU decorator for ZeroGPU
 
4
 
5
- # Decorate the function to indicate it needs GPU resources
6
  @GPU
7
- def generate_text(prompt):
8
- # Load the model within the function so that it only runs on GPU when the function is called
9
- model = pipeline("text-generation", model="EleutherAI/gpt-neo-125M", device=0)
10
-
11
- return model(prompt, max_length=200, temperature=0.7, top_p=0.9, stop=["."])[0]["generated_text"]
12
-
13
-
14
 
15
  # Create the Gradio interface
16
  interface = gr.Interface(
17
- fn=generate_text,
18
  inputs=gr.Textbox(label="Enter your prompt here"),
19
- outputs=gr.Textbox(label="Generated Text"),
20
- title="AI Text Generator",
21
- description="This app generates text based on your input prompt. Try it out!",
22
  theme="dark"
23
  )
24
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
  from spaces import GPU # Import the GPU decorator for ZeroGPU
4
+ from PIL import Image
5
 
6
+ # Use @GPU to allocate a GPU when running the video generation function
7
  @GPU
8
+ def generate_video(prompt):
9
+ # Load the Kandinsky video model
10
+ video_model = pipeline("video-generation", model="ai-forever/KandinskyVideo_1_1", device=0)
11
+ # Generate video based on the prompt
12
+ video = video_model(prompt)
13
+ return video # Ensure this returns the video file or frames
 
14
 
15
  # Create the Gradio interface
16
  interface = gr.Interface(
17
+ fn=generate_video,
18
  inputs=gr.Textbox(label="Enter your prompt here"),
19
+ outputs="video",
20
+ title="AI Video Generator",
21
+ description="This app generates a short video based on your input prompt using KandinskyVideo_1_1.",
22
  theme="dark"
23
  )
24
 
requirements.txt CHANGED
@@ -1,2 +1,4 @@
1
  gradio
2
- transformers==4.31.0
 
 
 
1
  gradio
2
+ transformers
3
+ torch
4
+ Pillow