Prashanthsrn commited on
Commit
21876ff
·
verified ·
1 Parent(s): 8b4c31a

Delete ui_components.py

Browse files
Files changed (1) hide show
  1. ui_components.py +0 -62
ui_components.py DELETED
@@ -1,62 +0,0 @@
1
- import streamlit as st
2
- from image_captioning import generate_caption
3
- from utils import copy_to_clipboard, get_image_file_buffer
4
-
5
- def create_sidebar():
6
- with st.sidebar:
7
- st.header("About")
8
- st.write("This AI Marketing Caption Generator helps create engaging captions for your product images.")
9
- st.write("Upload an image, and our AI will generate a caption tailored for marketing purposes.")
10
-
11
- st.header("Tips")
12
- st.write("- Use high-quality images for better results")
13
- st.write("- Try different images to see how the AI adapts")
14
- st.write("- Edit and refine the generated captions for your specific needs")
15
- st.write("- Use the regenerate button to get alternative captions")
16
-
17
- def create_main_content(image, initial_caption):
18
- st.header("Generated Caption")
19
- caption = st.text_area("Edit Caption", initial_caption, height=100)
20
-
21
- col1, col2 = st.columns(2)
22
- with col1:
23
- if st.button("Copy Caption"):
24
- copy_to_clipboard(caption)
25
-
26
- with col2:
27
- if st.button("Regenerate Caption"):
28
- with st.spinner("Regenerating caption..."):
29
- new_caption = generate_caption(image)
30
- st.session_state.caption = new_caption
31
- st.experimental_rerun()
32
-
33
- st.header("Customization Options")
34
- tone = st.selectbox("Tone", ["Professional", "Casual", "Humorous", "Formal"])
35
- length = st.slider("Caption Length", min_value=50, max_value=200, value=100, step=10)
36
-
37
- if st.button("Apply Customization"):
38
- with st.spinner("Applying customization..."):
39
- customized_caption = f"{caption}\n\nCustomized with {tone} tone, targeting {length} characters."
40
- st.text_area("Customized Caption", customized_caption, height=150)
41
-
42
- st.header("Caption Preview")
43
- st.markdown(f"*{caption}*")
44
-
45
- def display_image_upload():
46
- uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
47
-
48
- if uploaded_file is not None:
49
- image = Image.open(uploaded_file)
50
- st.image(image, caption="Uploaded Image", use_column_width=True)
51
-
52
- with st.spinner("Generating caption..."):
53
- try:
54
- if 'caption' not in st.session_state:
55
- st.session_state.caption = generate_caption(image)
56
- create_main_content(image, st.session_state.caption)
57
- except Exception as e:
58
- st.error(f"An error occurred while generating the caption: {str(e)}")
59
-
60
- return image
61
-
62
- return None