Spaces:
Running
Running
Commit
·
28471f6
1
Parent(s):
7d261da
up v9
Browse files
app.py
CHANGED
@@ -1,23 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
-
from models import make_inpainting
|
3 |
import io
|
4 |
from PIL import Image
|
5 |
import numpy as np
|
6 |
-
|
7 |
-
from PIL import Image
|
8 |
-
from typing import Union
|
9 |
-
import random
|
10 |
-
import numpy as np
|
11 |
-
import os
|
12 |
-
import time
|
13 |
-
|
14 |
from models import make_image_controlnet, make_inpainting
|
15 |
-
from segmentation import segment_image
|
16 |
-
from config import HEIGHT, WIDTH, POS_PROMPT, NEG_PROMPT, COLOR_MAPPING, map_colors, map_colors_rgb
|
17 |
-
from palette import COLOR_MAPPING_CATEGORY
|
18 |
from preprocessing import preprocess_seg_mask, get_image, get_mask
|
19 |
-
from explanation import make_inpainting_explanation, make_regeneration_explanation, make_segmentation_explanation
|
20 |
-
|
21 |
|
22 |
def image_to_byte_array(image: Image) -> bytes:
|
23 |
# BytesIO is a fake file stored in memory
|
@@ -29,21 +15,19 @@ def image_to_byte_array(image: Image) -> bytes:
|
|
29 |
return imgByteArr
|
30 |
|
31 |
def predict(input_img1,input_img2):
|
32 |
-
|
33 |
-
# image = Image.open(requests.get("https://applydesignblobs-chh5aahjdzh0cnew.z01.azurefd.net/spaceimages/org_sqr_7fee0869-3187-4363-b5fb-5233e943649d.png", stream=True).raw)
|
34 |
-
# mask = Image.open(requests.get("https://applydesign.blob.core.windows.net/spaceimages/mask_e85b1585-8.png", stream=True).raw)
|
35 |
|
36 |
canvas_mask = np.array(input_img2)
|
37 |
mask = get_mask(canvas_mask)
|
38 |
|
|
|
|
|
39 |
result_image = make_inpainting(positive_prompt='test1',
|
40 |
-
image=
|
41 |
mask_image=mask,
|
42 |
negative_prompt="xxx",
|
43 |
)
|
44 |
|
45 |
-
|
46 |
-
# predictions = pipeline(input_img1)
|
47 |
return result_image
|
48 |
|
49 |
gradio_app = gr.Interface(
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import io
|
3 |
from PIL import Image
|
4 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from models import make_image_controlnet, make_inpainting
|
|
|
|
|
|
|
6 |
from preprocessing import preprocess_seg_mask, get_image, get_mask
|
|
|
|
|
7 |
|
8 |
def image_to_byte_array(image: Image) -> bytes:
|
9 |
# BytesIO is a fake file stored in memory
|
|
|
15 |
return imgByteArr
|
16 |
|
17 |
def predict(input_img1,input_img2):
|
18 |
+
print("predict")
|
|
|
|
|
19 |
|
20 |
canvas_mask = np.array(input_img2)
|
21 |
mask = get_mask(canvas_mask)
|
22 |
|
23 |
+
print(input_img1, mask)
|
24 |
+
|
25 |
result_image = make_inpainting(positive_prompt='test1',
|
26 |
+
image=input_img1,
|
27 |
mask_image=mask,
|
28 |
negative_prompt="xxx",
|
29 |
)
|
30 |
|
|
|
|
|
31 |
return result_image
|
32 |
|
33 |
gradio_app = gr.Interface(
|