File size: 1,159 Bytes
44db148
 
368a20c
44db148
 
 
 
 
 
 
 
75d81ac
 
 
44db148
 
 
75d81ac
44db148
75d81ac
 
2102d9e
 
 
 
44db148
 
 
d9def72
44db148
d9def72
44db148
2102d9e
 
 
 
 
 
 
75d81ac
 
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
import io
from os import getenv
import gradio as gr
import requests
from PIL import Image

API_URL = (
    "https://api-inference.huggingface.co/models/ztjona/scopic-diffusion-OW-v1.4.1"
)
API_TOKEN = getenv("API_TOKEN")
headers = {"Authorization": f"Bearer {API_TOKEN}"}


def infer(prompt):
    payload = {"inputs": prompt}
    response = requests.post(API_URL, headers=headers, json=payload)
    image_bytes = response.content

    return Image.open(io.BytesIO(image_bytes))


demo = gr.Interface(
    fn=infer,
    inputs="text",
    outputs="image",
    examples=[
        ["city and clouds"],
        ["tea party"],
        ["chess player"],
        ["buddhist monk"],
        ["the man of the mask"],
    ],
    title="Generate images based on artist Oswaldo Guayasamín",
    description="Write a prompt and an image will be generated. ",
    article="""Fune tuned Stable Diffusion model. \n
    Instructions are located (here)[https://github.com/ztjona/scopic-diffusion]\n
    Check the training code in colab (here)[https://drive.google.com/file/d/1r1z8Ckqq4W9U0Wg0PcWGB_ri4DavpkCQ/view?usp=sharing]""",
    theme=gr.themes.Soft(),
)

demo.launch()