Omnibus commited on
Commit
5858c5c
1 Parent(s): 903810d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -10,7 +10,7 @@ import torch
10
  from diffusers import AutoPipelineForImage2Image
11
  from diffusers.utils import make_image_grid, load_image
12
 
13
-
14
  loaded_model=[]
15
  for i,model in enumerate(models):
16
  try:
@@ -20,19 +20,14 @@ for i,model in enumerate(models):
20
  pass
21
  print (loaded_model)
22
 
 
23
 
24
- def run_dif(out_prompt,model_drop,cnt):
25
- out_box=[]
26
 
27
- pipeline = AutoPipelineForImage2Image.from_pretrained(
28
- "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float32, use_safetensors=True
29
- )
30
- #pipeline.enable_model_cpu_offload()
31
- # remove following line if xFormers is not installed or you have PyTorch 2.0 or higher installed
32
- #pipeline.enable_xformers_memory_efficient_attention()
33
-
34
- # prepare image
35
- url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/img2img-init.png"
36
  init_image = load_image(url)
37
 
38
  prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
@@ -159,13 +154,14 @@ min-width:200px;
159
  """
160
  with gr.Blocks(css=css) as app:
161
  with gr.Row():
162
- inp=gr.Textbox(label="Prompt")
163
- btn=gr.Button()
164
-
 
165
  with gr.Row():
166
  model_drop=gr.Dropdown(label="Models", choices=models, type='index', value=models[0])
167
  cnt = gr.Number(value=1)
168
  out_html=gr.HTML()
169
  outp=gr.Gallery()
170
- btn.click(run_dif,[inp,model_drop,cnt],[outp,out_html])
171
  app.launch()
 
10
  from diffusers import AutoPipelineForImage2Image
11
  from diffusers.utils import make_image_grid, load_image
12
 
13
+ base_url=f'https://omnibus-top-20-img-img.hf.space/file='
14
  loaded_model=[]
15
  for i,model in enumerate(models):
16
  try:
 
20
  pass
21
  print (loaded_model)
22
 
23
+ pipeline = AutoPipelineForImage2Image.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float32, use_safetensors=True)
24
 
25
+ def load_model(model_drop):
26
+ pipeline = AutoPipelineForImage2Image.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float32, use_safetensors=True)
27
 
28
+ def run_dif(prompt,im_path,model_drop,cnt):
29
+ out_box=[]
30
+ url = base_url+im_path
 
 
 
 
 
 
31
  init_image = load_image(url)
32
 
33
  prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
 
154
  """
155
  with gr.Blocks(css=css) as app:
156
  with gr.Row():
157
+ with gr.Column():
158
+ inp=gr.Textbox(label="Prompt")
159
+ btn=gr.Button()
160
+ inp_im=gr.Image(type='filepath')
161
  with gr.Row():
162
  model_drop=gr.Dropdown(label="Models", choices=models, type='index', value=models[0])
163
  cnt = gr.Number(value=1)
164
  out_html=gr.HTML()
165
  outp=gr.Gallery()
166
+ btn.click(run_dif,[inp,inp_im,model_drop,cnt],[outp,out_html])
167
  app.launch()