Spaces:
Runtime error
Runtime error
Upload progress_bar.py
Browse files
diffusers_helper/gradio/progress_bar.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
progress_html = '''
|
| 2 |
+
<div class="loader-container">
|
| 3 |
+
<div class="loader"></div>
|
| 4 |
+
<div class="progress-container">
|
| 5 |
+
<progress value="*number*" max="100"></progress>
|
| 6 |
+
</div>
|
| 7 |
+
<span>*text*</span>
|
| 8 |
+
</div>
|
| 9 |
+
'''
|
| 10 |
+
|
| 11 |
+
css = '''
|
| 12 |
+
.loader-container {
|
| 13 |
+
display: flex; /* Use flex to align items horizontally */
|
| 14 |
+
align-items: center; /* Center items vertically within the container */
|
| 15 |
+
white-space: nowrap; /* Prevent line breaks within the container */
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.loader {
|
| 19 |
+
border: 8px solid #f3f3f3; /* Light grey */
|
| 20 |
+
border-top: 8px solid #3498db; /* Blue */
|
| 21 |
+
border-radius: 50%;
|
| 22 |
+
width: 30px;
|
| 23 |
+
height: 30px;
|
| 24 |
+
animation: spin 2s linear infinite;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
@keyframes spin {
|
| 28 |
+
0% { transform: rotate(0deg); }
|
| 29 |
+
100% { transform: rotate(360deg); }
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/* Style the progress bar */
|
| 33 |
+
progress {
|
| 34 |
+
appearance: none; /* Remove default styling */
|
| 35 |
+
height: 20px; /* Set the height of the progress bar */
|
| 36 |
+
border-radius: 5px; /* Round the corners of the progress bar */
|
| 37 |
+
background-color: #f3f3f3; /* Light grey background */
|
| 38 |
+
width: 100%;
|
| 39 |
+
vertical-align: middle !important;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/* Style the progress bar container */
|
| 43 |
+
.progress-container {
|
| 44 |
+
margin-left: 20px;
|
| 45 |
+
margin-right: 20px;
|
| 46 |
+
flex-grow: 1; /* Allow the progress container to take up remaining space */
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/* Set the color of the progress bar fill */
|
| 50 |
+
progress::-webkit-progress-value {
|
| 51 |
+
background-color: #3498db; /* Blue color for the fill */
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
progress::-moz-progress-bar {
|
| 55 |
+
background-color: #3498db; /* Blue color for the fill in Firefox */
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/* Style the text on the progress bar */
|
| 59 |
+
progress::after {
|
| 60 |
+
content: attr(value '%'); /* Display the progress value followed by '%' */
|
| 61 |
+
position: absolute;
|
| 62 |
+
top: 50%;
|
| 63 |
+
left: 50%;
|
| 64 |
+
transform: translate(-50%, -50%);
|
| 65 |
+
color: white; /* Set text color */
|
| 66 |
+
font-size: 14px; /* Set font size */
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/* Style other texts */
|
| 70 |
+
.loader-container > span {
|
| 71 |
+
margin-left: 5px; /* Add spacing between the progress bar and the text */
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.no-generating-animation > .generating {
|
| 75 |
+
display: none !important;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
'''
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def make_progress_bar_html(number, text):
|
| 82 |
+
return progress_html.replace('*number*', str(number)).replace('*text*', text)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def make_progress_bar_css():
|
| 86 |
+
return css
|