Commit
·
3ace1fb
1
Parent(s):
98d7d7c
Styling and Performance
Browse files- app.py +5 -5
- header.html +16 -31
app.py
CHANGED
@@ -19,6 +19,7 @@ auth_token = os.environ.get("API_TOKEN") or True
|
|
19 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
20 |
|
21 |
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-inpainting", dtype=torch.float16, revision="fp16", use_auth_token=auth_token)
|
|
|
22 |
|
23 |
transform = transforms.Compose([
|
24 |
transforms.ToTensor(),
|
@@ -35,10 +36,9 @@ def read_content(file_path: str) -> str:
|
|
35 |
return content
|
36 |
|
37 |
def predict(dict, prompt=""):
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
output = pipe(prompt = prompt, image=init_image, mask_image=mask,guidance_scale=7.5)
|
42 |
return output.images[0]
|
43 |
|
44 |
|
@@ -65,7 +65,7 @@ with image_blocks as demo:
|
|
65 |
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Upload").style(height=400)
|
66 |
|
67 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
68 |
-
prompt = gr.Textbox(label = 'Your prompt (what you want
|
69 |
btn = gr.Button("Generate image").style(
|
70 |
margin=False,
|
71 |
rounded=(False, True, True, False),
|
|
|
19 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
20 |
|
21 |
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-inpainting", dtype=torch.float16, revision="fp16", use_auth_token=auth_token)
|
22 |
+
pipe.to(device)
|
23 |
|
24 |
transform = transforms.Compose([
|
25 |
transforms.ToTensor(),
|
|
|
36 |
return content
|
37 |
|
38 |
def predict(dict, prompt=""):
|
39 |
+
init_image = dict["image"].convert("RGB").resize((512, 512))
|
40 |
+
mask = dict["mask"].convert("RGB").resize((512, 512))
|
41 |
+
output = pipe(prompt = prompt, image=init_image, mask_image=mask,guidance_scale=7.5)
|
|
|
42 |
return output.images[0]
|
43 |
|
44 |
|
|
|
65 |
image = gr.Image(source='upload', tool='sketch', elem_id="image_upload", type="pil", label="Upload").style(height=400)
|
66 |
|
67 |
with gr.Row(elem_id="prompt-container").style(mobile_collapse=False, equal_height=True):
|
68 |
+
prompt = gr.Textbox(label = 'Your prompt (what you want in place of what is erased)')
|
69 |
btn = gr.Button("Generate image").style(
|
70 |
margin=False,
|
71 |
rounded=(False, True, True, False),
|
header.html
CHANGED
@@ -1,38 +1,23 @@
|
|
1 |
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
2 |
-
|
3 |
-
style="
|
4 |
display: inline-flex;
|
5 |
gap: 0.8rem;
|
6 |
font-size: 1.75rem;
|
7 |
-
margin-bottom: 10px;
|
8 |
-
margin-left: 220px;
|
9 |
-
justify-content: center;
|
10 |
-
"
|
11 |
-
>
|
12 |
-
<a href="https://runwayml.com/"><img src="https://aeiljuispo.cloudimg.io/v7/https://s3.amazonaws.com/moonup/production/uploads/1665970599545-634cb15a4abe8405758d2e7e.jpeg" alt="RunwayML" width="30%"></a>
|
13 |
-
</div>
|
14 |
-
<div
|
15 |
-
style="
|
16 |
-
display: inline-flex;
|
17 |
-
align-items: center;
|
18 |
-
gap: 0.8rem;
|
19 |
-
font-size: 1.75rem;
|
20 |
-
margin-bottom: 10px;
|
21 |
justify-content: center;
|
22 |
">
|
23 |
-
<
|
|
|
|
|
|
|
24 |
RunwayML Stable Diffusion Inpainting 🎨
|
25 |
-
</h1
|
26 |
-
|
27 |
-
|
28 |
-
<p style="
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
</p>
|
37 |
-
</div>
|
38 |
-
</div>
|
|
|
1 |
<div style="text-align: center; max-width: 650px; margin: 0 auto;">
|
2 |
+
<div style="
|
|
|
3 |
display: inline-flex;
|
4 |
gap: 0.8rem;
|
5 |
font-size: 1.75rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
justify-content: center;
|
7 |
">
|
8 |
+
<img
|
9 |
+
src="https://aeiljuispo.cloudimg.io/v7/https://s3.amazonaws.com/moonup/production/uploads/1665970599545-634cb15a4abe8405758d2e7e.jpeg"
|
10 |
+
alt="RunwayML" width="64px">
|
11 |
+
<h1 style="font-weight: 900; align-items: center; margin-bottom: 7px; margin-top: 12px;">
|
12 |
RunwayML Stable Diffusion Inpainting 🎨
|
13 |
+
</h1>
|
14 |
+
</div>
|
15 |
+
<div>
|
16 |
+
<p style="align-items: center; margin-bottom: 7px;">
|
17 |
+
Stable Diffusion Inpainting, add a mask and text prompt for what you want to replace <br>For faster
|
18 |
+
generation you can try
|
19 |
+
<a href="https://app.runwayml.com/video-tools/teams/akhaliq/ai-tools/erase-and-replace"
|
20 |
+
style="text-decoration: underline;" target="_blank">erase and replace tool on Runway</a>
|
21 |
+
</p>
|
22 |
+
</div>
|
23 |
+
</div>
|
|
|
|
|
|