free-undress-ai / app.py
outsourceit2day's picture
Update app.py
9e06bcb verified
raw
history blame
2.37 kB
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
"""
main.py
How to run:
python main.py
"""
def mainTest(inputpath, outpath):
watermark = deep_nude_process(inputpath)
watermark1 = cv2.cvtColor(watermark, cv2.COLOR_BGRA2RGBA)
#cv2.imwrite(outpath, watermark1)
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 = "input_" + str(index) + ".jpg"
cv2.imwrite(inputpath, bgra)
outputpath = "out_" + str(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 = "Try Free Undress AI"
description = "<a href='https://nudify.info/download-apps-like-deepnude-alternatives/'>37 DeepNude Alternatives</a><br><br>Input photos, similar to the test picture at the bottom, and undress pictures will be produced. You may have to wait 30-50 seconds for a picture. πŸ”ž Do not upload personal photos or a photo without a permit. This has criminal consequences in some countries! πŸ”ž 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. If you have become a victim of Deepnude photos blackmail, contact your local police. This article describes the algorithm of actions and your rights in case of such a crime.<hr><h2>Use Free Undress AI</h2>"
examples = [
['input.png', 'Test'],
['input.jpg', 'Test'],
]
web = gr.Interface(inference,
inputs="image",
outputs="image",
title=title,
description=description,
examples=examples,
)
if __name__ == '__main__':
web.launch()