Spaces:
Runtime error
Runtime error
File size: 1,827 Bytes
c2eddce afd3c08 c2eddce c4bf23b afd3c08 c4bf23b c2eddce fcaff26 c4bf23b fcaff26 c2eddce fcaff26 c4bf23b fcaff26 c2eddce 68ad6f4 c2eddce |
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 |
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(bgra, outpath):
watermark = deep_nude_process(bgra)
#watermark1 = cv2.cvtColor(watermark, cv2.COLOR_RGBA2BGRA)
#cv2.imwrite(outpath, watermark1)
return watermark
#
def deep_nude_process(item):
# print('Processing {}'.format(item))
dress = cv2.imread(item)
#dress = cv2.cvtColor(dress, cv2.COLOR_BGRA2RGBA)
#dress = item
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("开始!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
output = mainTest(inputpath, outputpath)
print(time.strftime("结束!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
return output
title = "AI脱衣"
description = "传入人物照片,类似最下方测试图的那种,将制作脱衣图,一张图至少等40秒,别传私人照片"
examples = [
['input.png', '测试图'],
]
web = gr.Interface(inference,
inputs="image",
outputs="image",
title=title,
description=description,
examples=examples,
)
if __name__ == '__main__':
web.launch(
enable_queue=True
)
|