Spaces:
Running
on
Zero
Running
on
Zero
Upload 2 files
Browse files- app.py +28 -0
- requirements.txt +12 -0
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import torch
|
5 |
+
from ic_light.infer import infer_ic_light # 假设IC-Light提供一个infer方法
|
6 |
+
|
7 |
+
def run_ic_light(foreground_img, background_img, model_type="fbc+fc"):
|
8 |
+
result = infer_ic_light(
|
9 |
+
foreground_path=foreground_img.name,
|
10 |
+
background_path=background_img.name,
|
11 |
+
model_type=model_type
|
12 |
+
)
|
13 |
+
return Image.open(result)
|
14 |
+
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=run_ic_light,
|
17 |
+
inputs=[
|
18 |
+
gr.Image(type="file", label="Foreground Image"),
|
19 |
+
gr.Image(type="file", label="Background Image"),
|
20 |
+
gr.Radio(choices=["fc", "fbc", "fbc+fc"], label="Model Type", value="fbc+fc")
|
21 |
+
],
|
22 |
+
outputs=gr.Image(label="Relit Image"),
|
23 |
+
title="IC-Light Background Conditional Relighting",
|
24 |
+
description="Upload a foreground and a background image to perform IC-Light based relighting using background conditions."
|
25 |
+
)
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
gradio==3.41.2
|
3 |
+
torch
|
4 |
+
Pillow
|
5 |
+
opencv-python
|
6 |
+
einops
|
7 |
+
transformers==4.36.2
|
8 |
+
diffusers==0.27.2
|
9 |
+
safetensors
|
10 |
+
peft
|
11 |
+
protobuf==3.20
|
12 |
+
git+https://github.com/lllyasviel/IC-Light.git
|