Spaces:
Runtime error
Runtime error
File size: 2,844 Bytes
5a74a7f |
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 |
'''Pyxelate Demo
- Based on https://huggingface.co/spaces/akhaliq/Pyxelate
- Credits to akhaliq
2021-12-16 first created for testing
'''
import os
import io
from glob import glob
import gradio as gr
from skimage import io as sio
from pyxelate import Pyx, Pal
DOWNSAMPLE_MIN = 1
DOWNSAMPLE_MAX = 10
COLOR_MIN = 1
COLOR_MAX = 20
PALETTE_CHOICES = [
'none', # if not chosen
'TELETEXT', 'BBC_MICRO', 'CGA_MODE4_PAL1', 'CGA_MODE5_PAL1',
'CGA_MODE4_PAL2', 'ZX_SPECTRUM', 'APPLE_II_LO', 'APPLE_II_HI',
'COMMODORE_64', 'GAMEBOY_COMBO_UP', 'GAMEBOY_COMBO_DOWN', 'GAMEBOY_COMBO_LEFT',
'GAMEBOY_COMBO_RIGHT', 'GAMEBOY_A_UP', 'GAMEBOY_A_DOWN', 'GAMEBOY_A_LEFT',
'GAMEBOY_A_RIGHT', 'GAMEBOY_B_UP', 'GAMEBOY_B_DOWN', 'GAMEBOY_B_LEFT',
'GAMEBOY_B_RIGHT', 'GAMEBOY_ORIGINAL', 'GAMEBOY_POCKET', 'GAMEBOY_VIRTUALBOY',
'MICROSOFT_WINDOWS_16', 'MICROSOFT_WINDOWS_20', 'MICROSOFT_WINDOWS_PAINT',
'PICO_8', 'MSX', 'MONO_OBRADINN_IBM', 'MONO_OBRADINN_MAC', 'MONO_BJG', 'MONO_BW',
'MONO_PHOSPHOR_AMBER', 'MONO_PHOSPHOR_LTAMBER', 'MONO_PHOSPHOR_GREEN1',
'MONO_PHOSPHOR_GREEN2', 'MONO_PHOSPHOR_GREEN3', 'MONO_PHOSPHOR_APPLE', 'APPLE_II_MONO',
'MONO_PHOSPHOR_APPLEC', 'APPLE_II_MONOC'
]
DITHER_CHOICES = ['none', 'naive', 'bayer', 'floyd', 'atkinson']
def predict(image_obj, sampling_param, color_param, palette_param, dither_param):
return None
iface = gr.Interface(
predict,
title='์ด๋ฏธ์ง๋ฅผ ํฝ์
ํ ์ํค๋ ๋ฐ๋ชจ์
๋๋ค.',
description='์ด๋ฏธ์ง๊ฐ ์ฃผ์ด์ก์ ๋ ์ด๋ฏธ์ง๋ฅผ ์ค์ผ์ผ๋งํ๊ณ ์๊ฐ์ ๋ฐ๊พธ์ด ํฝ์
ํ ์ํฌ ์ ์์ต๋๋ค.',
inputs=[
gr.inputs.Image(label='์ธํ ์ด๋ฏธ์ง๋ฅผ ์ค๋นํด์ฃผ์ธ์'),
gr.inputs.Slider(label='๋ค์ด์ํํ ํฌ๊ธฐ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์ (ํด์๋ก ํฝ์
ํฌ๊ธฐ๊ฐ ์ปค์ง = ์ ํ์ง)',
minimum=DOWNSAMPLE_MIN, maximum=DOWNSAMPLE_MAX, step=1, default=5),
gr.inputs.Slider(label='์ฌ์ฉํ ์๊น์ ๊ฐ์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์ (์ ํ ์ ์๋ ํ๋ ํธ ์ค์ ์ ๋ฌด์๋ฉ๋๋ค)',
minimum=DOWNSAMPLE_MIN, maximum=DOWNSAMPLE_MAX, step=1, default=5),
gr.inputs.Dropdown(label='์๊น ํ๋ ํธ๋ฅผ ์ ํํ์ธ์ (์ ํ ์ ์์ ์๊น ๊ฐ์๋ ๋ฌด์๋ฉ๋๋ค)',
choices=PALETTE_CHOICES, default='none', type='value'),
gr.inputs.Dropdown(label='๊ฒฐ๊ณผ ์ด๋ฏธ์ง์ ๋ถ๋๋ฌ์ ์ ๋๋ฅผ ๋ํ๋
๋๋ค ("dithering")',
choices=DITHER_CHOICES, default='none', type='value'),
],
outputs=[
gr.outputs.Image(label='๊ฒฐ๊ณผ ์ด๋ฏธ์ง ์
๋๋ค')
],
# examples=examples,
enable_queue=True,
article='<p style="text-align:center">Credits to <a href="https://github.com/sedthh/pyxelate">GitHub</a></p>',
)
iface.launch(debug=True) |