Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,42 +3,54 @@ from huggingface_hub import InferenceClient
|
|
3 |
import base64
|
4 |
from io import BytesIO
|
5 |
from PIL import Image
|
6 |
-
|
|
|
7 |
# Define the list of models
|
8 |
models = [
|
9 |
-
"
|
10 |
-
"CompVis/stable-diffusion-v1-4",
|
11 |
-
"runwayml/stable-diffusion-v1-5",
|
12 |
-
"stabilityai/stable-diffusion-2-1-base",
|
13 |
-
"stabilityai/stable-diffusion-2-1",
|
14 |
-
"CompVis/ldm-text2im-large-256",
|
15 |
-
"lambdalabs/sd-text2img-base-2-0",
|
16 |
-
"ZB-Tech/Text-to-Image",
|
17 |
-
"cloudqi/cqi_text_to_image_pt_v0",
|
18 |
-
"kothariyashhh/GenAi-Texttoimage",
|
19 |
-
"sairajg/Text_To_Image"
|
20 |
]
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
response = client.text_to_image(prompt)
|
25 |
-
#image_data = response[0]['image']
|
26 |
-
#image = Image.open(BytesIO(base64.b64decode(response)))
|
27 |
return response
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Create Gradio Interface
|
36 |
with gr.Blocks() as demo:
|
37 |
-
gr.Markdown("##
|
38 |
with gr.Row():
|
39 |
with gr.Column():
|
40 |
model_dropdown = gr.Dropdown(models, label="Select Model")
|
41 |
-
prompt_input = gr.Textbox(label="Enter
|
|
|
42 |
generate_button = gr.Button("Generate Image")
|
43 |
with gr.Column():
|
44 |
output_image = gr.Image(label="Generated Image")
|
|
|
3 |
import base64
|
4 |
from io import BytesIO
|
5 |
from PIL import Image
|
6 |
+
import bs4
|
7 |
+
import lxml
|
8 |
# Define the list of models
|
9 |
models = [
|
10 |
+
"Qwen/Qwen2.5-Coder-32B-Instruct",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
]
|
12 |
+
def get_webpage_text(url):
|
13 |
+
source = requests.get(url)
|
14 |
+
isV('status: ', source.status_code)
|
15 |
+
if source.status_code ==200:
|
16 |
+
soup = bs4.BeautifulSoup(source.content,'lxml')
|
17 |
+
rawp=(f'RAW TEXT RETURNED: {soup.text}')
|
18 |
+
return rawp
|
19 |
+
else:
|
20 |
+
return "ERROR couldn't find, "+url
|
21 |
+
def generate_image(prompt):
|
22 |
+
client = InferenceClient("black-forest-labs/FLUX.1-dev")
|
23 |
response = client.text_to_image(prompt)
|
|
|
|
|
24 |
return response
|
25 |
+
|
26 |
+
|
27 |
+
def generate_prompt(company_name, company_url=""):
|
28 |
+
|
29 |
+
client = InferenceClient(model_name)
|
30 |
+
company_html = get_webpage_text(company_url)
|
31 |
+
|
32 |
+
system_prompt=f"""You are a Master Generative Image Prompt Writer, you know just the perfect prompt secrets for every situation
|
33 |
+
Today you will be generating Company Logo's
|
34 |
+
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
|
35 |
+
Company Name: {company_name}
|
36 |
+
HTML from Company Website: {company_html}"""
|
37 |
+
prompt_in=[
|
38 |
+
{'role':'system','content':system_prompt},
|
39 |
+
{'role':'user','content':prompt},
|
40 |
+
]
|
41 |
+
stream = client.text_generation(prompt_in, **self.generate_kwargs, stream=True, details=True, return_full_text=True)
|
42 |
+
for response in stream:
|
43 |
+
output += response.token.text
|
44 |
+
return output
|
45 |
|
46 |
# Create Gradio Interface
|
47 |
with gr.Blocks() as demo:
|
48 |
+
gr.Markdown("## Smart Logo Maker")
|
49 |
with gr.Row():
|
50 |
with gr.Column():
|
51 |
model_dropdown = gr.Dropdown(models, label="Select Model")
|
52 |
+
prompt_input = gr.Textbox(label="Enter Company Name")
|
53 |
+
prompt_input = gr.Textbox(label="Enter Company Name")
|
54 |
generate_button = gr.Button("Generate Image")
|
55 |
with gr.Column():
|
56 |
output_image = gr.Image(label="Generated Image")
|