File size: 2,458 Bytes
f7235bd
 
62d9bf1
 
 
39dd908
 
62d9bf1
f7235bd
39dd908
f7235bd
39dd908
 
 
 
 
 
 
 
 
 
bcab8fb
39dd908
 
 
bcab8fb
39dd908
bcab8fb
39dd908
 
 
 
 
 
 
 
 
f7235bd
bcab8fb
 
 
 
 
 
 
 
f7235bd
 
39dd908
f7235bd
 
bcab8fb
 
 
f7235bd
 
 
 
bcab8fb
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
62
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_prompt(company_name, company_html, company_descp):
    client = InferenceClient(model_name)
    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, Description, 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}
    Company Description: {company_descp}
    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

        
def generate_image(comp_name, comp_desc, comp_url):
    web_out=get_webpage_text(comp_url)
    prompt_out=generate_prompt(comp_name,web_out, comp_desc)
    client = InferenceClient("black-forest-labs/FLUX.1-dev")
    response = client.text_to_image(prompt)
    return response

# Create Gradio Interface
with gr.Blocks() as demo:
    gr.Markdown("## Smart Logo Maker")
    with gr.Row():
        with gr.Column():
            comp_name = gr.Textbox(label="Enter Company Name")
            comp_desc = gr.Textbox(label="Enter Company Description (optional)")
            comp_url = gr.Textbox(label="Enter Company URL (optional)")
            generate_button = gr.Button("Generate Image")
        with gr.Column():
            output_image = gr.Image(label="Generated Image")
    
    generate_button.click(generate_image, inputs=[comp_name, comp_desc, comp_url], outputs=output_image)

# Launch the interface
demo.launch()