File size: 1,019 Bytes
94ff45f
c5c13ba
 
d1b4bf4
94ff45f
14c265d
9e46964
 
5ef35db
2076a84
5ef35db
932ecd2
 
5ef35db
 
25651c2
94ff45f
c5c13ba
 
932ecd2
 
c5c13ba
 
 
 
 
 
 
 
 
 
 
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
from diffusers import DiffusionPipeline
import gradio as gr
import numpy as np
import os

from huggingface_hub import login
import os

# Retrieve the token from an environment variable
access_token = os.getenv('HF_TOKEN')  # Replace with the correct variable name

if access_token is None:
    raise ValueError("Token is not set in the environment variable.")

# Log in using the token
login(token=access_token)

# Define a function that takes a text input and returns an image.
def text_to_image(text : str):
    pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
    pipe.load_lora_weights("gokaygokay/Flux-Game-Assets-LoRA-v2")
    prompt = text
    image = pipe(prompt).images[0]
    return image

# Create a Gradio interface that takes a textbox input, runs it through the text_to_image function, and returns output to an image.
demo = gr.Interface(fn=text_to_image, inputs="textbox", outputs="image")

# Launch the interface.
if __name__ == "__main__":
    demo.launch(show_error=True)