DrElaheJ's picture
update
d444930 verified
raw
history blame contribute delete
966 Bytes
import gradio as gr
from huggingface_hub import InferenceClient
# def saveData(prompt,image):
# import csv
# with open('/images/prompts.csv', 'a') as f:
# w=csv.writer(f)
# w.writerow([prompt])
# image.save('/impages/'+prompt+'.jpeg')
def imageGen(prompt):
model_name="https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
client=InferenceClient(model=model_name)
output=client.text_to_image(prompt)
#saveData(prompt,output)
return output
with gr.Blocks(theme=gr.themes.Citrus()) as demo:
with gr.Row():
with gr.Column():
#an image input
prompt = gr.Textbox(label="your prompt",scale=1)
describe_btn = gr.Button("Generate Image",scale=1)
with gr.Column():
image=gr.Image(type="pil", label="your image")
#sending the prompt to function to get an image
describe_btn.click(fn=imageGen, inputs= prompt, outputs=image)
demo.launch(debug=True, share=True)