Yaron Koresh commited on
Commit
bc115c5
·
verified ·
1 Parent(s): 4541cda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -19
app.py CHANGED
@@ -9,25 +9,15 @@ import gradio as gr
9
  import numpy as np
10
  from lxml.html import fromstring
11
  from pathos.threading import ThreadPool as Pool
12
- from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
13
- #from diffusers.pipelines.flux import FluxPipeline
14
- from diffusers.utils import export_to_gif
15
- from huggingface_hub import hf_hub_download
16
- from safetensors.torch import load_file
17
 
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
  dtype = torch.float16
20
-
21
- step = 2
22
- repo = "ByteDance/AnimateDiff-Lightning"
23
- ckpt = f"animatediff_lightning_{step}step_diffusers.safetensors"
24
- base = "emilianJR/epiCRealism"
25
-
26
- adapter = MotionAdapter().to(device, dtype)
27
- adapter.load_state_dict(load_file(hf_hub_download(repo ,ckpt), device=device))
28
- pipe = AnimateDiffPipeline.from_pretrained(base, motion_adapter=adapter, torch_dtype=dtype).to(device)
29
- pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", beta_schedule="linear")
30
-
31
  pipe.enable_vae_slicing()
32
  pipe.enable_vae_tiling()
33
 
@@ -89,14 +79,14 @@ def generate_random_string(length):
89
  characters = string.ascii_letters + string.digits
90
  return ''.join(random.choice(characters) for _ in range(length))
91
 
92
- @spaces.GPU(duration=45)
93
  def Piper(_do):
94
  return pipe(
95
  _do,
96
  height=256,
97
  width=768,
98
- num_frames=16,
99
- num_inference_steps=step,
100
  guidance_scale=7
101
  )
102
 
 
9
  import numpy as np
10
  from lxml.html import fromstring
11
  from pathos.threading import ThreadPool as Pool
12
+ #from diffusers import DiffusionPipeline, AnimateDiffPipeline, MotionAdapter, EulerDiscreteScheduler
13
+ from diffusers.pipelines.flux import FluxPipeline
14
+ #from diffusers.utils import export_to_gif
15
+ #from huggingface_hub import hf_hub_download
16
+ #from safetensors.torch import load_file
17
 
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
  dtype = torch.float16
20
+ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=dtype).to(device)
 
 
 
 
 
 
 
 
 
 
21
  pipe.enable_vae_slicing()
22
  pipe.enable_vae_tiling()
23
 
 
79
  characters = string.ascii_letters + string.digits
80
  return ''.join(random.choice(characters) for _ in range(length))
81
 
82
+ @spaces.GPU(duration=35)
83
  def Piper(_do):
84
  return pipe(
85
  _do,
86
  height=256,
87
  width=768,
88
+ num_inference_steps=50,
89
+ max_sequence_length=512,
90
  guidance_scale=7
91
  )
92