Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,6 @@ def inference(img):
|
|
38 |
output = mainTest(inputpath, outputpath)
|
39 |
print(time.strftime("Finish!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
|
40 |
return output
|
41 |
-
from PIL import Image
|
42 |
|
43 |
def load_image_from_file(file_path, new_height=None):
|
44 |
"""
|
@@ -54,7 +53,7 @@ def load_image_from_file(file_path, new_height=None):
|
|
54 |
try:
|
55 |
img = Image.open(file_path)
|
56 |
|
57 |
-
if new_height is not None:
|
58 |
# Calculate new width to maintain aspect ratio
|
59 |
aspect_ratio = img.width / img.height
|
60 |
new_width = int(new_height * aspect_ratio)
|
@@ -207,34 +206,23 @@ window.onDemoLoad = function(x){
|
|
207 |
}
|
208 |
</script>
|
209 |
'''
|
210 |
-
|
211 |
-
<div style="background-color: #f0f0f0; padding: 10px; border-radius: 5px; text-align: center; margin-top: 20px;">
|
212 |
-
<p style="font-size: 16px; color: #333;">
|
213 |
-
For the full version and more exciting NSFW AI apps, visit
|
214 |
-
<a href="https://nsfwais.io?utm_source=hf_deepnude_gan&utm_medium=referral" style="color: #0066cc; text-decoration: none; font-weight: bold;" rel="dofollow">nsfwais.io</a>!
|
215 |
-
</p>
|
216 |
-
</div>
|
217 |
-
'''
|
218 |
with gr.Blocks(css=css, head=js) as demo:
|
219 |
width=240
|
220 |
height=340
|
221 |
|
222 |
with gr.Row(equal_height=False):
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
process_button = gr.Button("Nude!",size="sm")
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
|
232 |
def update_status(img):
|
233 |
processed_img = inference(img)
|
234 |
return processed_img
|
235 |
-
|
236 |
-
image_input.change(fn=lambda x:x
|
237 |
process_button.click(update_status, inputs=image_input, outputs=image_input, js='''(i) => window.postMessageToParent(i, "process_started", "demo_hf_deepnude_gan_card", "click_nude")''')
|
238 |
-
demo.load(fn=lambda x:x, inputs=[gr.State([])], outputs=[gr.State([])], js='''(x)=>window.onDemoLoad(x)''')
|
239 |
demo.queue(max_size=10)
|
240 |
-
demo.launch()
|
|
|
38 |
output = mainTest(inputpath, outputpath)
|
39 |
print(time.strftime("Finish!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
|
40 |
return output
|
|
|
41 |
|
42 |
def load_image_from_file(file_path, new_height=None):
|
43 |
"""
|
|
|
53 |
try:
|
54 |
img = Image.open(file_path)
|
55 |
|
56 |
+
if (new_height is not None):
|
57 |
# Calculate new width to maintain aspect ratio
|
58 |
aspect_ratio = img.width / img.height
|
59 |
new_width = int(new_height * aspect_ratio)
|
|
|
206 |
}
|
207 |
</script>
|
208 |
'''
|
209 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
with gr.Blocks(css=css, head=js) as demo:
|
211 |
width=240
|
212 |
height=340
|
213 |
|
214 |
with gr.Row(equal_height=False):
|
215 |
+
with gr.Column(min_width=240): # Adjust scale for proper sizing
|
216 |
+
image_input = gr.Image(type="numpy", label="", height=height)
|
217 |
+
gr.Examples(examples=examples, inputs=image_input, examples_per_page=10, elem_id="example_img")
|
218 |
+
process_button = gr.Button("Nude!", size="sm")
|
|
|
|
|
|
|
|
|
219 |
|
220 |
def update_status(img):
|
221 |
processed_img = inference(img)
|
222 |
return processed_img
|
223 |
+
|
224 |
+
image_input.change(fn=lambda x: x, inputs=[image_input], outputs=[gr.State([])], js='''(img) => window.uploadImage(img, "process_finished", "demo_hf_deepnude_gan_card", "")''')
|
225 |
process_button.click(update_status, inputs=image_input, outputs=image_input, js='''(i) => window.postMessageToParent(i, "process_started", "demo_hf_deepnude_gan_card", "click_nude")''')
|
226 |
+
demo.load(fn=lambda x: x, inputs=[gr.State([])], outputs=[gr.State([])], js='''(x) => window.onDemoLoad(x)''')
|
227 |
demo.queue(max_size=10)
|
228 |
+
demo.launch()
|