Spaces:
Running
Running
import click | |
import dotenv | |
import segno | |
from huggingface_hub import InferenceClient | |
from qrcode_artistic import write_artistic | |
from segno.consts import ERROR_MAPPING | |
from myapp.palette import extract_color_clusters, generate_palette_image | |
from myapp.params import ImageParamType | |
dotenv.load_dotenv() | |
client = InferenceClient() | |
def cli(): | |
pass | |
def generate_image(prompt, target, model, width, height): | |
image = client.text_to_image( | |
prompt=prompt, | |
model=model, | |
width=width, | |
height=height, | |
) | |
image.save(target) | |
def generate_palette(image, target, n_colors, shades): | |
k_means = extract_color_clusters(image, n_colors) | |
palette = generate_palette_image(k_means, shades=shades) | |
palette.save(target) | |
def generate_qr_code(text, background, target, scale, error): | |
write_artistic( | |
segno.make(text, error=error), | |
background.filename, | |
target, | |
scale=scale, | |
) | |