Spaces:
Runtime error
Runtime error
Commit
·
eff32bf
1
Parent(s):
8034168
np array
Browse files
app.py
CHANGED
|
@@ -2,6 +2,8 @@ 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 |
|
|
@@ -14,12 +16,15 @@ def image_to_byte_array(image: Image) -> bytes:
|
|
| 14 |
imgByteArr = imgByteArr.getvalue()
|
| 15 |
return imgByteArr
|
| 16 |
|
| 17 |
-
def predict(input_img1,
|
|
|
|
| 18 |
|
| 19 |
print("predict")
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
input_img1 = input_img1.resize((
|
| 22 |
-
input_img2 = input_img2.resize((
|
| 23 |
|
| 24 |
canvas_mask = np.array(input_img2)
|
| 25 |
mask = get_mask(canvas_mask)
|
|
@@ -36,8 +41,8 @@ def predict(input_img1,input_img2):
|
|
| 36 |
|
| 37 |
gradio_app = gr.Interface(
|
| 38 |
predict,
|
| 39 |
-
inputs=[gr.Image(label="img", sources=['upload', 'webcam'], type="
|
| 40 |
-
gr.Image(label="mask", sources=['upload', 'webcam'], type="
|
| 41 |
],
|
| 42 |
outputs= gr.Image(label="resp"),
|
| 43 |
title="rem fur 1",
|
|
|
|
| 2 |
import io
|
| 3 |
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
+
|
| 6 |
+
from config import WIDTH, HEIGHT
|
| 7 |
from models import make_image_controlnet, make_inpainting
|
| 8 |
from preprocessing import preprocess_seg_mask, get_image, get_mask
|
| 9 |
|
|
|
|
| 16 |
imgByteArr = imgByteArr.getvalue()
|
| 17 |
return imgByteArr
|
| 18 |
|
| 19 |
+
def predict(input_img1,
|
| 20 |
+
input_img2):
|
| 21 |
|
| 22 |
print("predict")
|
| 23 |
+
input_img1 = Image.fromarray(input_img1)
|
| 24 |
+
input_img2 = Image.fromarray(input_img2)
|
| 25 |
|
| 26 |
+
input_img1 = input_img1.resize((WIDTH, HEIGHT))
|
| 27 |
+
input_img2 = input_img2.resize((WIDTH, WIDTH))
|
| 28 |
|
| 29 |
canvas_mask = np.array(input_img2)
|
| 30 |
mask = get_mask(canvas_mask)
|
|
|
|
| 41 |
|
| 42 |
gradio_app = gr.Interface(
|
| 43 |
predict,
|
| 44 |
+
inputs=[gr.Image(label="img", sources=['upload', 'webcam'], type="numpy"),
|
| 45 |
+
gr.Image(label="mask", sources=['upload', 'webcam'], type="numpy")
|
| 46 |
],
|
| 47 |
outputs= gr.Image(label="resp"),
|
| 48 |
title="rem fur 1",
|