Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 5.26.0
|
| 8 |
-
app_file:
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: imageslider_main
|
| 4 |
+
emoji: 🔥
|
| 5 |
+
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 5.26.0
|
| 9 |
+
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
+
hf_oauth: true
|
| 12 |
---
|
|
|
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@eff532b913a3c8f06f10a4f9471d3177e3744053#subdirectory=client/python
|
| 2 |
+
https://gradio-pypi-previews.s3.amazonaws.com/eff532b913a3c8f06f10a4f9471d3177e3744053/gradio-5.26.0-py3-none-any.whl
|
run.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: imageslider"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from PIL import ImageFilter\n", "\n", "\n", "def img_to_slider(im):\n", " if not im:\n", " return im\n", " return (im, im.filter(filter=ImageFilter.GaussianBlur(radius=10)))\n", "\n", "\n", "def slider_to_self(im):\n", " if not im or not im[0]:\n", " return im\n", " return (im[0], im[0].filter(filter=ImageFilter.GaussianBlur(radius=10)))\n", "\n", "\n", "def slider_to_self_two(im):\n", " return im\n", "\n", "\n", "def position_to_slider(pos):\n", " return gr.ImageSlider(slider_position=pos)\n", "\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\"## img to image slider\")\n", " with gr.Row():\n", " img1 = gr.Image(label=\"Blur image\", type=\"pil\")\n", " img2 = gr.ImageSlider(label=\"Blur image\", type=\"pil\")\n", " btn = gr.Button(\"Blur image\")\n", " btn.click(img_to_slider, inputs=img1, outputs=img2)\n", " gr.Markdown(\"## unified image slider\")\n", " with gr.Row():\n", " img3 = gr.ImageSlider(label=\"Blur image\", type=\"pil\")\n", " img3.upload(slider_to_self, inputs=img3, outputs=img3)\n", " pos = gr.Slider(label=\"Position\", value=50, minimum=0, maximum=100, step=0.01)\n", " pos.change(position_to_slider, inputs=pos, outputs=img3, show_progress=\"hidden\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import ImageFilter
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def img_to_slider(im):
|
| 6 |
+
if not im:
|
| 7 |
+
return im
|
| 8 |
+
return (im, im.filter(filter=ImageFilter.GaussianBlur(radius=10)))
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def slider_to_self(im):
|
| 12 |
+
if not im or not im[0]:
|
| 13 |
+
return im
|
| 14 |
+
return (im[0], im[0].filter(filter=ImageFilter.GaussianBlur(radius=10)))
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def slider_to_self_two(im):
|
| 18 |
+
return im
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def position_to_slider(pos):
|
| 22 |
+
return gr.ImageSlider(slider_position=pos)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown("## img to image slider")
|
| 27 |
+
with gr.Row():
|
| 28 |
+
img1 = gr.Image(label="Blur image", type="pil")
|
| 29 |
+
img2 = gr.ImageSlider(label="Blur image", type="pil")
|
| 30 |
+
btn = gr.Button("Blur image")
|
| 31 |
+
btn.click(img_to_slider, inputs=img1, outputs=img2)
|
| 32 |
+
gr.Markdown("## unified image slider")
|
| 33 |
+
with gr.Row():
|
| 34 |
+
img3 = gr.ImageSlider(label="Blur image", type="pil")
|
| 35 |
+
img3.upload(slider_to_self, inputs=img3, outputs=img3)
|
| 36 |
+
pos = gr.Slider(label="Position", value=50, minimum=0, maximum=100, step=0.01)
|
| 37 |
+
pos.change(position_to_slider, inputs=pos, outputs=img3, show_progress="hidden")
|
| 38 |
+
|
| 39 |
+
if __name__ == "__main__":
|
| 40 |
+
demo.launch()
|