Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,17 @@
|
|
|
|
1 |
import time
|
|
|
|
|
|
|
2 |
import cv2
|
3 |
-
import
|
4 |
-
import gradio as gr
|
5 |
from PIL import Image
|
|
|
|
|
6 |
|
|
|
7 |
index = 1
|
8 |
|
9 |
-
def process(dress):
|
10 |
-
# Dummy processing function for demonstration
|
11 |
-
# Replace with your actual processing logic
|
12 |
-
return cv2.GaussianBlur(dress, (15, 15), 0)
|
13 |
-
|
14 |
def mainTest(inputpath, outpath):
|
15 |
watermark = deep_nude_process(inputpath)
|
16 |
watermark1 = cv2.cvtColor(watermark, cv2.COLOR_BGRA2RGBA)
|
@@ -27,17 +28,16 @@ def deep_nude_process(inputpath):
|
|
27 |
|
28 |
def inference(img):
|
29 |
global index
|
30 |
-
img = np.array(img) # Convert PIL image to NumPy array
|
31 |
bgra = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
|
32 |
-
inputpath =
|
33 |
cv2.imwrite(inputpath, bgra)
|
34 |
|
35 |
-
outputpath =
|
36 |
index += 1
|
37 |
print(time.strftime("START!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
|
38 |
output = mainTest(inputpath, outputpath)
|
39 |
print(time.strftime("Finish!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
|
40 |
-
return
|
41 |
|
42 |
title = "Undress AI"
|
43 |
description = "β Input photos of people, similar to the test picture at the bottom, and undress pictures will be produced. You may have to wait 30 seconds for a picture. π Do not upload personal photos π There is a queue system. According to the logic of first come, first served, only one picture will be made at a time. Must be able to at least see the outline of a human body β"
|
@@ -47,15 +47,16 @@ examples = [
|
|
47 |
['input.jpg', 'Test'],
|
48 |
]
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
59 |
|
60 |
if __name__ == '__main__':
|
61 |
web.launch()
|
|
|
1 |
+
from run import process
|
2 |
import time
|
3 |
+
import subprocess
|
4 |
+
import os
|
5 |
+
import argparse
|
6 |
import cv2
|
7 |
+
import sys
|
|
|
8 |
from PIL import Image
|
9 |
+
import torch
|
10 |
+
import gradio as gr
|
11 |
|
12 |
+
TESTdevice = "cpu"
|
13 |
index = 1
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
def mainTest(inputpath, outpath):
|
16 |
watermark = deep_nude_process(inputpath)
|
17 |
watermark1 = cv2.cvtColor(watermark, cv2.COLOR_BGRA2RGBA)
|
|
|
28 |
|
29 |
def inference(img):
|
30 |
global index
|
|
|
31 |
bgra = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
|
32 |
+
inputpath = "input_" + str(index) + ".jpg"
|
33 |
cv2.imwrite(inputpath, bgra)
|
34 |
|
35 |
+
outputpath = "out_" + str(index) + ".jpg"
|
36 |
index += 1
|
37 |
print(time.strftime("START!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
|
38 |
output = mainTest(inputpath, outputpath)
|
39 |
print(time.strftime("Finish!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
|
40 |
+
return output
|
41 |
|
42 |
title = "Undress AI"
|
43 |
description = "β Input photos of people, similar to the test picture at the bottom, and undress pictures will be produced. You may have to wait 30 seconds for a picture. π Do not upload personal photos π There is a queue system. According to the logic of first come, first served, only one picture will be made at a time. Must be able to at least see the outline of a human body β"
|
|
|
47 |
['input.jpg', 'Test'],
|
48 |
]
|
49 |
|
50 |
+
def update_image(img):
|
51 |
+
return gr.update(value=inference(img))
|
52 |
+
|
53 |
+
web = gr.Interface(fn=update_image,
|
54 |
+
inputs=gr.Image(type="numpy", label="Upload Image"),
|
55 |
+
outputs=gr.Image(type="numpy", label="Processed Image"),
|
56 |
+
title=title,
|
57 |
+
description=description,
|
58 |
+
examples=examples,
|
59 |
+
)
|
60 |
|
61 |
if __name__ == '__main__':
|
62 |
web.launch()
|