orderlymirror commited on
Commit
3e16b59
·
verified ·
1 Parent(s): 82ce274

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -29
app.py CHANGED
@@ -37,18 +37,11 @@ feature_extractor = CLIPFeatureExtractor.from_pretrained("openai/clip-vit-base-p
37
 
38
  # Function
39
  @spaces.GPU(duration=30,queue=False)
40
- def generate_image(prompt, base="Realistic", motion="", step=8, resolution="Square", progress=gr.Progress()):
41
  global step_loaded
42
  global base_loaded
43
  global motion_loaded
44
-
45
- print(prompt, base, step, resolution)
46
-
47
- # Set resolution
48
- if resolution == "Square":
49
- width, height = 512, 512
50
- elif resolution == "Horizontal":
51
- width, height = 1280, 720
52
 
53
  if step_loaded != step:
54
  repo = "ByteDance/AnimateDiff-Lightning"
@@ -71,7 +64,7 @@ def generate_image(prompt, base="Realistic", motion="", step=8, resolution="Squa
71
  def progress_callback(i, t, z):
72
  progress((i+1, step))
73
 
74
- output = pipe(prompt=prompt, guidance_scale=1.2, num_inference_steps=step, width=width, height=height, callback=progress_callback, callback_steps=1)
75
 
76
  name = str(uuid.uuid4()).replace("-", "")
77
  path = f"/tmp/{name}.mp4"
@@ -83,7 +76,7 @@ def generate_image(prompt, base="Realistic", motion="", step=8, resolution="Squa
83
  with gr.Blocks(css="style.css") as demo:
84
  gr.HTML(
85
  "<h1><center>Textual Imagination : A Text To Video Synthesis</center></h1>"
86
- )
87
  with gr.Group():
88
  with gr.Row():
89
  prompt = gr.Textbox(
@@ -128,15 +121,6 @@ with gr.Blocks(css="style.css") as demo:
128
  value=4,
129
  interactive=True
130
  )
131
- select_resolution = gr.Dropdown(
132
- label='Resolution',
133
- choices=[
134
- "Square",
135
- "Horizontal",
136
- ],
137
- value="Square",
138
- interactive=True
139
- )
140
  submit = gr.Button(
141
  scale=1,
142
  variant='primary'
@@ -149,16 +133,15 @@ with gr.Blocks(css="style.css") as demo:
149
  elem_id="video_output"
150
  )
151
 
152
- gr.on(
153
- triggers=[
154
  submit.click,
155
  prompt.submit
156
- ],
157
- fn=generate_image,
158
- inputs=[prompt, select_base, select_motion, select_step, select_resolution],
159
- outputs=[video],
160
- api_name="instant_video",
161
- queue=False
162
  )
163
 
164
- demo.queue().launch()
 
37
 
38
  # Function
39
  @spaces.GPU(duration=30,queue=False)
40
+ def generate_image(prompt, base="Realistic", motion="", step=8, progress=gr.Progress()):
41
  global step_loaded
42
  global base_loaded
43
  global motion_loaded
44
+ print(prompt, base, step)
 
 
 
 
 
 
 
45
 
46
  if step_loaded != step:
47
  repo = "ByteDance/AnimateDiff-Lightning"
 
64
  def progress_callback(i, t, z):
65
  progress((i+1, step))
66
 
67
+ output = pipe(prompt=prompt, guidance_scale=1.2, num_inference_steps=step, callback=progress_callback, callback_steps=1)
68
 
69
  name = str(uuid.uuid4()).replace("-", "")
70
  path = f"/tmp/{name}.mp4"
 
76
  with gr.Blocks(css="style.css") as demo:
77
  gr.HTML(
78
  "<h1><center>Textual Imagination : A Text To Video Synthesis</center></h1>"
79
+ )
80
  with gr.Group():
81
  with gr.Row():
82
  prompt = gr.Textbox(
 
121
  value=4,
122
  interactive=True
123
  )
 
 
 
 
 
 
 
 
 
124
  submit = gr.Button(
125
  scale=1,
126
  variant='primary'
 
133
  elem_id="video_output"
134
  )
135
 
136
+ gr.on(triggers=[
 
137
  submit.click,
138
  prompt.submit
139
+ ],
140
+ fn = generate_image,
141
+ inputs = [prompt, select_base, select_motion, select_step],
142
+ outputs = [video],
143
+ api_name = "instant_video",
144
+ queue = False
145
  )
146
 
147
+ demo.queue().launch(share=True)