Spaces:
Running
Running
File size: 2,298 Bytes
f7235bd 62d9bf1 39dd908 62d9bf1 f7235bd 39dd908 f7235bd 39dd908 f7235bd c989c4e 39dd908 f7235bd 39dd908 f7235bd 39dd908 f7235bd |
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 |
import gradio as gr
from huggingface_hub import InferenceClient
import base64
from io import BytesIO
from PIL import Image
import bs4
import lxml
# Define the list of models
models = [
"Qwen/Qwen2.5-Coder-32B-Instruct",
]
def get_webpage_text(url):
source = requests.get(url)
isV('status: ', source.status_code)
if source.status_code ==200:
soup = bs4.BeautifulSoup(source.content,'lxml')
rawp=(f'RAW TEXT RETURNED: {soup.text}')
return rawp
else:
return "ERROR couldn't find, "+url
def generate_image(prompt):
client = InferenceClient("black-forest-labs/FLUX.1-dev")
response = client.text_to_image(prompt)
return response
def generate_prompt(company_name, company_url=""):
client = InferenceClient(model_name)
company_html = get_webpage_text(company_url)
system_prompt=f"""You are a Master Generative Image Prompt Writer, you know just the perfect prompt secrets for every situation
Today you will be generating Company Logo's
You will be given a Company Name, and HTML artifacts from their website, use this to generate a sufficiently long and detailed image generation prompt to satisfy the users request, make sure that the company name is the focal point of the image
Company Name: {company_name}
HTML from Company Website: {company_html}"""
prompt_in=[
{'role':'system','content':system_prompt},
{'role':'user','content':prompt},
]
stream = client.text_generation(prompt_in, **self.generate_kwargs, stream=True, details=True, return_full_text=True)
for response in stream:
output += response.token.text
return output
# Create Gradio Interface
with gr.Blocks() as demo:
gr.Markdown("## Smart Logo Maker")
with gr.Row():
with gr.Column():
model_dropdown = gr.Dropdown(models, label="Select Model")
prompt_input = gr.Textbox(label="Enter Company Name")
prompt_input = gr.Textbox(label="Enter Company Name")
generate_button = gr.Button("Generate Image")
with gr.Column():
output_image = gr.Image(label="Generated Image")
generate_button.click(generate_image, inputs=[prompt_input, model_dropdown], outputs=output_image)
# Launch the interface
demo.launch() |