File size: 2,693 Bytes
ee7f7d6 d948530 271a7bc c2eddce 07d05ef c2eddce b4d6bb3 c2eddce b4d6bb3 c2eddce fcaff26 92f472f c4bf23b ee7f7d6 92f472f c2eddce 4da45b0 c4bf23b 4da45b0 60efdc5 c2eddce ee7f7d6 b4d8694 2391de5 ee7f7d6 d948530 ee7f7d6 2391de5 996dc92 2391de5 cd18648 ee7f7d6 b4d8694 ee7f7d6 b4d8694 cd18648 d5259b4 b4d8694 2391de5 b5a7f02 c2eddce ee7f7d6 d63ccb2 509b60d cd18648 996dc92 ee7f7d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
from run import process
import time
import subprocess
import os
import argparse
import cv2
import sys
from PIL import Image
import torch
import gradio as gr
TESTdevice = "cpu"
index = 1
def mainTest(inputpath, outpath):
watermark = deep_nude_process(inputpath)
watermark1 = cv2.cvtColor(watermark, cv2.COLOR_BGRA2RGBA)
return watermark1
def deep_nude_process(inputpath):
dress = cv2.imread(inputpath)
h = dress.shape[0]
w = dress.shape[1]
dress = cv2.resize(dress, (512, 512), interpolation=cv2.INTER_CUBIC)
watermark = process(dress)
watermark = cv2.resize(watermark, (w, h), interpolation=cv2.INTER_CUBIC)
return watermark
def inference(img):
global index
bgra = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
inputpath = f"input_{index}.jpg"
cv2.imwrite(inputpath, bgra)
outputpath = f"out_{index}.jpg"
index += 1
print(time.strftime("START!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
output = mainTest(inputpath, outputpath)
print(time.strftime("Finish!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
return output
title = "Undress AI"
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 β"
examples = [
['example1.png'],
['example2.png'],
['example3.png'],
['example5.webp'],
['example6.webp'],
]
css = """
body {
background-color: rgb(17, 24, 39);
color: white;
}
.gradio-container {
background-color: rgb(17, 24, 39) !important;
border: none !important;
}
#example_img .hide-container{
height:80px;
width:100%;
transition: transform 0.5s ease;
}
#example_img{
width:100%;
}
#example_img img{
height:80px;
width:50px;
transition: transform 0.5s ease;
}
footer {display: none !important;}
"""
with gr.Blocks(css=css) as demo:
width=320
height=240
with gr.Row():
with gr.Column(scale=2): # Adjust scale for proper sizing
image_input = gr.Image(type="numpy", label="Upload Image", width=width, height=height)
gr.Examples(examples=examples, inputs=image_input, examples_per_page=5, elem_id="example_img")
process_button = gr.Button("Nude!")
def update_status(img):
processed_img = inference(img)
return processed_img
process_button.click(update_status, inputs=image_input, outputs=image_input)
demo.queue(max_size=10)
demo.launch()
|