Spaces:
Runtime error
Runtime error
File size: 6,012 Bytes
bf8129e 037ec46 bf8129e 037ec46 |
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
import subprocess
from ultralytics import YOLO
import streamlit as st
from PIL import Image
# Command to install ultalytics using pip
install_command = "pip install ultalytics"
# Use subprocess to execute the command
subprocess.run(install_command, shell=True)
if __name__ == '__main__':
st.set_page_config(layout="wide")
myhtml = '''
<div class="topnav" id="home">
<div class= "logo">
<a href="#">
<h3 style="font-size: 2.3rem;">Bubble-Detector</h3>
</a>
</div>
<div class = "links">
<a href="#speech-bubble-detector">Home</a>
<a href="#speech-bubble-detection">Detector</a>
<a href="#about">About</a>
<a style="color: black; background: white; padding: 0 3em; display: flex; align-items: center"
href="https://github.com/AymanKUMA/yolov8_speech_bubbles_detection">Github</a>
</div>
</div>
<div class="hidden">
</div>
<div class="content">
<div class="home">
<h1 id="home">Speech Bubble Detector</h1>
<p>Revolutionize Manga and Comic Reading Experience with YOLOv8
</br>The Cutting-Edge Model That Detects Speech Bubbles with Unmatched Precision</p>
</div>
</div>
'''
style = '''
<style>
body {
background-image: url("https://wallpapercave.com/wp/wp8578059.jpg");
background-blend-mode: multiply;
background-color: gray;
background-size: cover;
}
.topnav {
overflow: hidden;
background-color: #333;
padding: 0rem 1rem;
display: flex;
justify-content: space-between;
position: fixed;
top: 0;
width: 100%;
z-index: 9999999999;
}
.logo a{
text-decoration: none;
}
.links{
width: 40%;
display: flex;
justify-content: space-around;
}
.links a{
display: block;
color: #f2f2f2;
text-align: center;
padding: 20px 10px;
text-decoration: none;
}
.hidden{
height: 5rem;
}
.content{
display: flex;
align-items: center;
justify-content: center;
}
.home{
width: 80%;
background-color: #00000080;
padding: 60px;
}
.home h1{
font-size: 6rem;
}
.home p{
font-size: 1.5rem;
}
main {
margin: 20px;
width: 80%;
background-color: #00000080;
padding: 60px;
}
.down{
display: flex;
align-items: center;
justify-content: center;
}
section {
margin-bottom: 40px;
}
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.gallery img {
margin: 10px;
max-width: 400px;
max-height: 400px;
}
.e19lei0e1{
display: none;
}
.e8zbici2{
display: none;
}
.e1tzin5v0{
gap: 0rem;
}
.egzxvld4{
padding: 0rem 0rem;
}
.egzxvld1{
display: none;
}
.css-ffhzg2{
background: none;
}
.css-keje6w{
padding: 2rem 5rem;
flex: 1 1 calc(100% - 1rem);
}
.e16nr0p32{
display: none;
}
.footer{
buttom: 0;
width: 100%;
padding: 1.3rem;
text-align: center;
color: white;
background-color: #333;
zindex: 9999999
}
</style>
'''
st.markdown(style, unsafe_allow_html=True)
st.markdown(myhtml, unsafe_allow_html=True)
col1, col2, col3 = st.columns((2, 1, 1))
with col1:
st.title('Speech bubble detection ')
uploaded_file = st.file_uploader("Load image", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
is_valid = True
with st.spinner(text='Uploading image...'):
with col2:
st.image(uploaded_file, caption="Input Page", use_column_width=True)
picture = Image.open(uploaded_file)
else:
is_valid = False
if is_valid:
with col3:
with st.spinner(text='Processing image...'):
model = YOLO('best.pt')
results = model.predict(task="detect", source=picture, conf=0.85)
img = results[0].plot()
st.image(img, caption="Detected Objects", use_column_width=True)
my2ndHtml = '''
<div class="down">
<main>
<section>
<h2>About</h2>
<p>Our model detects speech bubbles from manga and comics using YOLOv8 by ultralytics. With a custom dataset of 2000 images, our model is able to accurately detect and classify speech bubbles in a wide range of styles and formats.</p>
<p>Speech bubbles are an essential part of comic books and manga, allowing characters to speak and express emotions. Our model makes it easy to extract speech bubbles from images, making it a valuable tool for researchers, artists, and publishers alike.</p>
<p>This model is for academic use ONLY. Do not use it for any commercial purpose.</p>
</section>
<section>
<h2>Examples</h2>
<div class="gallery">
<img src=" https://drive.google.com/uc?id=1KJYsh3OX-WGAq5o_1P5k9ElvgOkt978w" alt="Example 1">
<img src="https://drive.google.com/uc?id=1fVvDcxzI46PTn0qRZwBTT6ReaVMNZIbI" alt="Example 2">
<img src="https://drive.google.com/uc?id=1pRBYx4P7_iTsNp3uV8ZeUQHvapWvBkO4" alt="Example 3">
<img src="https://drive.google.com/uc?id=1oxx4rrlHAa0nXU2vRXjaumghdN2czia-" alt="Example 4">
</div>
</section>
</main>
</div>
'''
st.markdown(my2ndHtml, unsafe_allow_html=True)
my3rdHtml = '''<div class="footer">© Speech Bubble Detector</div>'''
st.markdown(my3rdHtml, unsafe_allow_html=True) |