usmanyousaf commited on
Commit
514dc3a
β€’
1 Parent(s): 7115787
Files changed (2) hide show
  1. app.py +103 -0
  2. model.h5 +3 -0
app.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from PIL import Image
4
+ from io import BytesIO
5
+
6
+ # Set Streamlit page configuration
7
+ st.set_page_config(page_title="Sketch to Image using GAN", layout="centered")
8
+
9
+ # Custom CSS for styling
10
+ st.markdown("""
11
+ <style>
12
+ body {
13
+ background-color: #1e1e1e; /* Black background */
14
+ color: #ffffff; /* White text */
15
+ }
16
+ .main {
17
+ background-color: #1e1e1e; /* Black background */
18
+ }
19
+ h1, h2 {
20
+ color: #ff6347; /* Tomato color for titles */
21
+ }
22
+ .stButton>button {
23
+ color: #ffffff;
24
+ background-color: #ff6347; /* Tomato color for buttons */
25
+ border-radius: 10px;
26
+ border: 2px solid #ffffff;
27
+ }
28
+ </style>
29
+ """, unsafe_allow_html=True)
30
+
31
+ # Title with colors and emojis
32
+ st.markdown("<h1 style='text-align: center;'>Sketch to Image using GAN πŸ–ŒοΈ</h1>", unsafe_allow_html=True)
33
+
34
+ # Slide plane with three sections: Home, About, and Upload Pic
35
+ section = st.sidebar.radio("Navigate", ["Home", "About", "Upload Pic"])
36
+
37
+ # Home Section
38
+ if section == "Home":
39
+ st.markdown("<h2 style='text-align: center;'>Empowering Multiple Fields with GANs 🌐</h2>", unsafe_allow_html=True)
40
+ st.write("The application of Generative Adversarial Networks (GANs) in the Sketch to Image project extends beyond creative endeavors, finding significant utility in various fields. The ability to transform sketches into vibrant and detailed images has far-reaching implications, especially in sectors such as law enforcement, forensic science, and more.")
41
+ st.image("home.jpeg", caption="Sketch Example", width=300)
42
+ st.write("In law enforcement and police investigations, where visual evidence plays a crucial role, this technology provides a novel approach to enhancing and understanding sketches. The generated images offer a clearer representation, aiding investigators in identifying suspects and solving cases more efficiently.")
43
+ st.image("home1.jpeg", caption="Sketch Example", width=300)
44
+ st.write("Moreover, the applications of this project are not limited to forensics. In creative fields, such as digital art and design, artists can benefit from the seamless transformation of conceptual sketches into visually striking images. The project acts as a bridge between imagination and reality, providing a valuable tool for artists to bring their ideas to life.")
45
+
46
+ st.write("In essence, the Sketch to Image project stands as a testament to the versatility and transformative power of GANs. It is a technological innovation that has the potential to revolutionize the way we perceive and utilize visual data in various professional domains.")
47
+
48
+ # Add more details and images to make the page attractive
49
+
50
+
51
+ # About Section
52
+ elif section == "About":
53
+ st.markdown("<h2 style='text-align: center;'>About the Sketch to Image Project 🌟</h2>", unsafe_allow_html=True)
54
+ st.write("Greetings! I am Sidra, and I am excited to present my Final Year Project (FYP) titled 'Sketch to Image using GAN.' This project is a culmination of my passion for artificial intelligence, machine learning, and their real-world applications.")
55
+
56
+ st.write("The Sketch to Image project is centered around leveraging the power of Generative Adversarial Networks (GANs) to transform sketches into vibrant and realistic images. GANs, a class of machine learning models, are particularly adept at generating new data that closely resembles existing samples. This capability makes them an ideal choice for creative projects like converting sketches into colorful masterpieces.")
57
+ st.image("o2.jpg", caption="Sketch Example", width=300)
58
+ st.write("The motivation behind this project stems from the desire to bridge the gap between the conceptual and the tangible. Sketches, often the initial step in the creative process, are transformed into visually appealing images with the help of advanced machine learning algorithms. This transformation opens up new possibilities in fields such as digital art, forensic science, and more.")
59
+
60
+ st.write("One of the primary applications of this project lies in forensic investigations. The ability to convert rough sketches into detailed images can significantly enhance the accuracy and efficiency of investigations. It provides law enforcement agencies with a valuable tool for visualizing and understanding evidence, ultimately contributing to more effective decision-making.")
61
+ # st.image("about1.jpeg", caption="Sketch Example", width=200)
62
+ col1, col2 = st.columns(2)
63
+ col1.image("about1.jpeg", caption="Sketch Example", width=170)
64
+ col2.image("about 2.jpeg", caption="Sketch Example", width=150)
65
+ st.write("As the developer of this project, I am thrilled about the potential impact it can have on various fields. Whether used for creative expression, forensic analysis, or other applications, the Sketch to Image project represents the intersection of technology and creativity.")
66
+ # st.image("about 2.jpeg", caption="Sketch Example", width=200)
67
+ st.write("I invite you to explore the project and witness firsthand the transformative capabilities of GANs. Feel free to navigate through the different sections and experience the magic of turning sketches into vibrant images!")
68
+
69
+ # Add more details and images to make the page attractive
70
+
71
+
72
+
73
+ # Upload Pic Section
74
+ else:
75
+ st.markdown("<h2 style='text-align: center;'>Upload Your Sketch πŸ“€</h2>", unsafe_allow_html=True)
76
+ uploaded_file = st.file_uploader("Choose an image... πŸ“€", type=["jpg", "jpeg", "png"])
77
+
78
+ if uploaded_file is not None:
79
+ # Display the uploaded image in the center
80
+ col1, col2, col3 = st.columns([1, 2, 1])
81
+ with col2:
82
+ st.image(uploaded_file, caption="Uploaded Image πŸ–ΌοΈ", width=300)
83
+
84
+ # Button to generate the image with emoji
85
+ if st.button('Generate πŸš€'):
86
+ # Display a message while generating the image
87
+ with st.spinner('Wait for it... Generating your image 🎨'):
88
+ # Prepare the file for sending
89
+ files = {"file": uploaded_file.getvalue()}
90
+
91
+ # Send POST request to FastAPI server
92
+ response = requests.post("http://127.0.0.1:8000/generate-image/", files=files)
93
+
94
+ if response.status_code == 200:
95
+ # Convert the response content to an image
96
+ generated_image = Image.open(BytesIO(response.content))
97
+
98
+ # Display the generated image in the center
99
+ col1, col2, col3 = st.columns([1, 2, 1])
100
+ with col2:
101
+ st.image(generated_image, caption="Generated Image ✨", width=300)
102
+ else:
103
+ st.error("Error in image generation 😒")
model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fb6de4f52a88ce29b9e6e7b30c88e1eabfac34a8de960f62a680669f8dd92cd
3
+ size 217877032