Spaces:
Running
on
Zero
Running
on
Zero
Stephen
commited on
Commit
·
b77025c
1
Parent(s):
1f35c64
add api
Browse files- app.py +7 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -15,6 +15,7 @@ from transformers import CLIPTextModel, CLIPTokenizer
|
|
15 |
from briarmbg import BriaRMBG
|
16 |
from enum import Enum
|
17 |
from torch.hub import download_url_to_file
|
|
|
18 |
|
19 |
|
20 |
# 'stablediffusionapi/realistic-vision-v51'
|
@@ -332,6 +333,10 @@ def process_relight(input_fg, input_bg, prompt, image_width, image_height, num_s
|
|
332 |
results = [(x * 255.0).clip(0, 255).astype(np.uint8) for x in results]
|
333 |
return results + extra_images
|
334 |
|
|
|
|
|
|
|
|
|
335 |
|
336 |
@spaces.GPU
|
337 |
@torch.inference_mode()
|
@@ -463,6 +468,8 @@ with block:
|
|
463 |
return gal[evt.index]['name']
|
464 |
|
465 |
bg_gallery.select(bg_gallery_selected, inputs=bg_gallery, outputs=input_bg)
|
|
|
|
|
466 |
|
467 |
|
468 |
block.launch(server_name='0.0.0.0')
|
|
|
15 |
from briarmbg import BriaRMBG
|
16 |
from enum import Enum
|
17 |
from torch.hub import download_url_to_file
|
18 |
+
from loadimg import load_img
|
19 |
|
20 |
|
21 |
# 'stablediffusionapi/realistic-vision-v51'
|
|
|
333 |
results = [(x * 255.0).clip(0, 255).astype(np.uint8) for x in results]
|
334 |
return results + extra_images
|
335 |
|
336 |
+
def fn(fg, bg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, bg_source):
|
337 |
+
input_fg = load_img(fg, output_type="numpy")
|
338 |
+
input_bg = load_img(bg, output_type="numpy")
|
339 |
+
return process_relight(input_fg, input_bg, prompt, image_width, image_height, num_samples, seed, steps, a_prompt, n_prompt, cfg, highres_scale, highres_denoise, bg_source)
|
340 |
|
341 |
@spaces.GPU
|
342 |
@torch.inference_mode()
|
|
|
468 |
return gal[evt.index]['name']
|
469 |
|
470 |
bg_gallery.select(bg_gallery_selected, inputs=bg_gallery, outputs=input_bg)
|
471 |
+
|
472 |
+
gr.Interface(fn, inputs=ips, outputs=[result_gallery], api_name="fn")
|
473 |
|
474 |
|
475 |
block.launch(server_name='0.0.0.0')
|
requirements.txt
CHANGED
@@ -8,3 +8,4 @@ torch
|
|
8 |
peft
|
9 |
gradio
|
10 |
protobuf
|
|
|
|
8 |
peft
|
9 |
gradio
|
10 |
protobuf
|
11 |
+
loadimg
|