gaur3009 commited on
Commit
ec81866
·
verified ·
1 Parent(s): dfc3114

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -34
app.py CHANGED
@@ -3,7 +3,6 @@ import requests
3
  from PIL import Image
4
  from io import BytesIO
5
  from tqdm import tqdm
6
- import os
7
  import time
8
 
9
  repo = "artificialguybr/TshirtDesignRedmond-V2"
@@ -43,26 +42,12 @@ def infer(color_prompt, phone_type_prompt, design_prompt):
43
  else:
44
  raise Exception(f"API Error: {response.status_code}")
45
 
46
- # Save the design
47
  def save_design(image):
48
- saved_designs_dir = "saved_designs"
49
- os.makedirs(saved_designs_dir, exist_ok=True)
50
- file_path = os.path.join(saved_designs_dir, f"design_{int(time.time())}.png")
51
  image.save(file_path)
52
  return f"Design saved as {file_path}!"
53
 
54
- # Fetch saved designs for display on the Home page
55
- def fetch_saved_designs():
56
- saved_designs_dir = "saved_designs"
57
- if not os.path.exists(saved_designs_dir):
58
- return []
59
-
60
- designs = []
61
- for file_name in os.listdir(saved_designs_dir):
62
- if file_name.endswith((".png", ".jpg", ".jpeg")):
63
- designs.append(os.path.join(saved_designs_dir, file_name))
64
- return designs
65
-
66
  # Custom CSS for animations
67
  custom_css = """
68
  body {
@@ -94,6 +79,16 @@ body::before {
94
  custom_js = """
95
  <script>
96
  document.addEventListener('DOMContentLoaded', function () {
 
 
 
 
 
 
 
 
 
 
97
  // Text-to-speech functionality
98
  function speak(text) {
99
  const synth = window.speechSynthesis;
@@ -119,22 +114,8 @@ with gr.Blocks(css=custom_css) as interface:
119
  # Navigation Tabs
120
  with gr.Tabs():
121
  with gr.Tab("Home"):
122
- gr.Markdown("Welcome to the **AI Phone Cover Designer**! Below are some of your saved designs.")
123
-
124
- saved_images_gallery = gr.Gallery(label="Saved Designs", show_label=True)
125
-
126
- refresh_button = gr.Button("Refresh Gallery")
127
-
128
- def refresh_gallery():
129
- return fetch_saved_designs()
130
-
131
- refresh_button.click(
132
- refresh_gallery,
133
- inputs=[],
134
- outputs=[saved_images_gallery]
135
- )
136
-
137
-
138
  with gr.Tab("Design"):
139
  with gr.Row():
140
  with gr.Column(scale=1):
@@ -161,7 +142,7 @@ with gr.Blocks(css=custom_css) as interface:
161
  )
162
 
163
  with gr.Tab("About"):
164
- gr.Markdown("""
165
  ## About AI Phone Cover Maker
166
  The **AI Phone Cover Maker** is a cutting-edge tool designed to help users create personalized phone cover designs quickly and easily.
167
  Powered by AI, it uses advanced image generation techniques to craft unique, high-quality designs for any mobile device.
 
3
  from PIL import Image
4
  from io import BytesIO
5
  from tqdm import tqdm
 
6
  import time
7
 
8
  repo = "artificialguybr/TshirtDesignRedmond-V2"
 
42
  else:
43
  raise Exception(f"API Error: {response.status_code}")
44
 
45
+ # Function to save the design
46
  def save_design(image):
47
+ file_path = "saved_design.png"
 
 
48
  image.save(file_path)
49
  return f"Design saved as {file_path}!"
50
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  # Custom CSS for animations
52
  custom_css = """
53
  body {
 
79
  custom_js = """
80
  <script>
81
  document.addEventListener('DOMContentLoaded', function () {
82
+ // Add particles
83
+ const particlesContainer = document.createElement('div');
84
+ particlesContainer.classList.add('particles');
85
+ for (let i = 0; i < 5; i++) {
86
+ const particle = document.createElement('div');
87
+ particle.classList.add('particle');
88
+ particlesContainer.appendChild(particle);
89
+ }
90
+ document.body.appendChild(particlesContainer);
91
+
92
  // Text-to-speech functionality
93
  function speak(text) {
94
  const synth = window.speechSynthesis;
 
114
  # Navigation Tabs
115
  with gr.Tabs():
116
  with gr.Tab("Home"):
117
+ gr.Markdown("Welcome to the **AI Phone Cover Designer**! Use the 'Design' tab to start creating custom designs.")
118
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  with gr.Tab("Design"):
120
  with gr.Row():
121
  with gr.Column(scale=1):
 
142
  )
143
 
144
  with gr.Tab("About"):
145
+ gr.Markdown("""
146
  ## About AI Phone Cover Maker
147
  The **AI Phone Cover Maker** is a cutting-edge tool designed to help users create personalized phone cover designs quickly and easily.
148
  Powered by AI, it uses advanced image generation techniques to craft unique, high-quality designs for any mobile device.