Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -393,6 +393,60 @@ def main():
|
|
393 |
else:
|
394 |
st.warning("Please enter an image description.")
|
395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
|
397 |
# Save chat history as PDF
|
398 |
if st.button("Save Chat History as PDF"):
|
|
|
393 |
else:
|
394 |
st.warning("Please enter an image description.")
|
395 |
|
396 |
+
elif search_type == "Logo Generation":
|
397 |
+
st.title("AI Logo Generator 🎨")
|
398 |
+
st.write("Generate a unique logo for your business using AI!")
|
399 |
+
|
400 |
+
# User Inputs
|
401 |
+
prompt = st.text_input("Enter a description for the logo:", "Make a logo for my gaming company BTZ")
|
402 |
+
style = st.selectbox("Select a Logo Style:", [28, 29, 30], index=0) # Customize styles if needed
|
403 |
+
size = st.radio("Select Image Size:", ["1-1", "2-3", "3-4"], index=0)
|
404 |
+
|
405 |
+
def generate_logo(prompt, style, size):
|
406 |
+
api_url = "https://ai-logo-generator.p.rapidapi.com/aaaaaaaaaaaaaaaaaiimagegenerator/quick.php"
|
407 |
+
headers = {
|
408 |
+
"x-rapidapi-key": LOGO_API_KEY,
|
409 |
+
"x-rapidapi-host": "ai-logo-generator.p.rapidapi.com",
|
410 |
+
"Content-Type": "application/json"
|
411 |
+
}
|
412 |
+
payload = {
|
413 |
+
"prompt": prompt,
|
414 |
+
"style_id": style,
|
415 |
+
"size": size
|
416 |
+
}
|
417 |
+
|
418 |
+
response = requests.post(api_url, json=payload, headers=headers)
|
419 |
+
return response.json()
|
420 |
+
|
421 |
+
# Generate button
|
422 |
+
if st.button("Generate Logo"):
|
423 |
+
with st.spinner("Generating logo... Please wait!"):
|
424 |
+
result = generate_logo(prompt, style, size)
|
425 |
+
|
426 |
+
# Extracting image URLs from the JSON response
|
427 |
+
image_data = result.get("final_result", [])
|
428 |
+
|
429 |
+
if image_data:
|
430 |
+
st.subheader("Generated Logo Designs")
|
431 |
+
|
432 |
+
for index, image in enumerate(image_data):
|
433 |
+
image_url = image.get("origin") # Extracting the logo link
|
434 |
+
|
435 |
+
if image_url:
|
436 |
+
st.image(image_url, caption=f"Logo Design {index+1}", use_container_width=True)
|
437 |
+
|
438 |
+
# Download button with a unique key
|
439 |
+
st.download_button(
|
440 |
+
label="Download Logo",
|
441 |
+
data=requests.get(image_url).content,
|
442 |
+
file_name=f"logo_design_{index+1}.webp",
|
443 |
+
mime="image/webp",
|
444 |
+
key=f"download_{index}" # Unique key to prevent duplicate errors
|
445 |
+
)
|
446 |
+
else:
|
447 |
+
st.error("Failed to generate logo. No image URL found.")
|
448 |
+
st.write("Response Data:", result) # Debugging: Show full response data
|
449 |
+
|
450 |
|
451 |
# Save chat history as PDF
|
452 |
if st.button("Save Chat History as PDF"):
|