Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
-
os.system("
|
3 |
-
os.system("unzip big-lama.zip")
|
4 |
import cv2
|
5 |
import paddlehub as hub
|
6 |
import gradio as gr
|
@@ -8,6 +7,8 @@ import torch
|
|
8 |
from PIL import Image, ImageOps
|
9 |
import numpy as np
|
10 |
os.mkdir("data")
|
|
|
|
|
11 |
os.mkdir("dataout")
|
12 |
model = hub.Module(name='U2Net')
|
13 |
def infer(img,mask,option):
|
@@ -27,7 +28,7 @@ def infer(img,mask,option):
|
|
27 |
mask = mask.resize((width,height))
|
28 |
im = mask
|
29 |
im.save("./data/data_mask.png")
|
30 |
-
os.system('python predict.py model.path=/home/user/app/
|
31 |
return "./dataout/data_mask.png",im
|
32 |
|
33 |
inputs = [gr.inputs.Image(type='pil', label="Original Image"),gr.inputs.Image(type='pil',source="canvas", label="Mask",invert_colors=True),gr.inputs.Radio(choices=["automatic (U2net)","manual"], type="value", default="manual", label="Masking option")]
|
|
|
1 |
import os
|
2 |
+
os.system("wget https://huggingface.co/akhaliq/lama/resolve/main/best.ckpt")
|
|
|
3 |
import cv2
|
4 |
import paddlehub as hub
|
5 |
import gradio as gr
|
|
|
7 |
from PIL import Image, ImageOps
|
8 |
import numpy as np
|
9 |
os.mkdir("data")
|
10 |
+
os.mkdir("models")
|
11 |
+
os.rename("best.ckpt", "models/best.ckpt")
|
12 |
os.mkdir("dataout")
|
13 |
model = hub.Module(name='U2Net')
|
14 |
def infer(img,mask,option):
|
|
|
28 |
mask = mask.resize((width,height))
|
29 |
im = mask
|
30 |
im.save("./data/data_mask.png")
|
31 |
+
os.system('python predict.py model.path=/home/user/app/ indir=/home/user/app/data/ outdir=/home/user/app/dataout/ device=cpu')
|
32 |
return "./dataout/data_mask.png",im
|
33 |
|
34 |
inputs = [gr.inputs.Image(type='pil', label="Original Image"),gr.inputs.Image(type='pil',source="canvas", label="Mask",invert_colors=True),gr.inputs.Radio(choices=["automatic (U2net)","manual"], type="value", default="manual", label="Masking option")]
|