DigiP-AI commited on
Commit
bbf10b7
·
verified ·
1 Parent(s): 312a433

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -43
app.py CHANGED
@@ -1,16 +1,25 @@
1
  import gradio as gr
 
 
 
 
2
  import base64
3
  import requests
4
  import os
 
5
  from PIL import Image
6
  from io import BytesIO
7
- from mistralai import Mistral
 
8
  from theme import theme
9
  from fastapi import FastAPI
10
 
11
  app = FastAPI()
12
 
13
-
 
 
 
14
 
15
  api_key = os.getenv("MISTRAL_API_KEY")
16
  Mistralclient = Mistral(api_key=api_key)
@@ -71,30 +80,6 @@ def feifeichat(image):
71
  print(f"Error: {e}")
72
  return "Please upload a photo"
73
 
74
-
75
- with gr.Blocks(theme=theme, elem_id="app-container") as app:
76
- gr.Markdown("Image To Flux Prompt")
77
- with gr.Tab(label="Image To Prompt"):
78
- with gr.Row():
79
- with gr.Column():
80
- input_img = gr.Image(label="Input Picture",height=320,type="filepath")
81
- submit_btn = gr.Button(value="Submit", variant='primary')
82
- with gr.Column():
83
- output_text = gr.Textbox(label="Flux Prompt", show_copy_button = True)
84
- clr_button =gr.Button("Clear",variant="primary", elem_id="clear_button")
85
- clr_button.click(lambda: gr.Textbox(value=""), None, output_text)
86
-
87
- submit_btn.click(feifeichat, [input_img], [output_text])
88
-
89
- # Project by Nymbo
90
- # Edited by DigiP-AI
91
-
92
- API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3.5-large-turbo"
93
- API_TOKEN = os.getenv("HF_READ_TOKEN")
94
- headers = {"Authorization": f"Bearer {API_TOKEN}"}
95
- timeout = 100
96
-
97
- # Function to clear input and output
98
  def clear():
99
  return None
100
 
@@ -163,7 +148,30 @@ footer{display:none !important}
163
  margin-left: auto;
164
  margin-right: auto;
165
  }
166
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
  # Build the Gradio UI with Blocks
169
  with gr.Blocks(theme=theme, css=css) as app:
@@ -217,22 +225,7 @@ with gr.Blocks(theme=theme, css=css) as app:
217
  # Bind the button to the query function with the added width and height inputs
218
  text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
219
 
220
-
221
- with gr.TabItem("Tips", visible=True):
222
- with gr.Row():
223
- gr.Markdown(
224
- """
225
- <div style="max-width: 650px; margin: 2rem auto; padding: 1rem; border-radius: 10px; background-color: #f0f0f0;">
226
- <h2 style="font-size: 1.5rem; margin-bottom: 1rem;">How to Use</h2>
227
- <ol style="padding-left: 1.5rem;">
228
- <li>Enter a detailed description of the image you want to create.</li>
229
- <li>Adjust advanced settings if desired (tap to expand).</li>
230
- <li>Tap "Generate Image" and wait for your creation!</li>
231
- </ol>
232
- <p style="margin-top: 1rem; font-style: italic;">Tip: Be specific in your description for best results!</p>
233
- </div>
234
- """
235
- )
236
 
237
 
238
  if __name__ == "__main__":
 
1
  import gradio as gr
2
+ import io
3
+ import random
4
+ import time
5
+ import json
6
  import base64
7
  import requests
8
  import os
9
+ from mistralai import Mistral
10
  from PIL import Image
11
  from io import BytesIO
12
+ from deep_translator import GoogleTranslator
13
+ from datetime import datetime
14
  from theme import theme
15
  from fastapi import FastAPI
16
 
17
  app = FastAPI()
18
 
19
+ API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-3.5-large-turbo"
20
+ API_TOKEN = os.getenv("HF_READ_TOKEN")
21
+ headers = {"Authorization": f"Bearer {API_TOKEN}"}
22
+ timeout = 100
23
 
24
  api_key = os.getenv("MISTRAL_API_KEY")
25
  Mistralclient = Mistral(api_key=api_key)
 
80
  print(f"Error: {e}")
81
  return "Please upload a photo"
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  def clear():
84
  return None
85
 
 
148
  margin-left: auto;
149
  margin-right: auto;
150
  }
151
+ """
152
+
153
+
154
+ with gr.Blocks(theme=theme, elem_id="app-container") as app:
155
+ gr.Markdown("Image To Flux Prompt")
156
+ with gr.Tab(label="Image To Prompt"):
157
+ with gr.Row():
158
+ with gr.Column():
159
+ input_img = gr.Image(label="Input Picture",height=320,type="filepath")
160
+ submit_btn = gr.Button(value="Submit", variant='primary')
161
+ with gr.Column():
162
+ output_text = gr.Textbox(label="Flux Prompt", show_copy_button = True)
163
+ clr_button =gr.Button("Clear",variant="primary", elem_id="clear_button")
164
+ clr_button.click(lambda: gr.Textbox(value=""), None, output_text)
165
+
166
+ submit_btn.click(feifeichat, [input_img], [output_text])
167
+
168
+ # Project by Nymbo
169
+ # Edited by DigiP-AI
170
+
171
+
172
+
173
+ # Function to clear input and output
174
+
175
 
176
  # Build the Gradio UI with Blocks
177
  with gr.Blocks(theme=theme, css=css) as app:
 
225
  # Bind the button to the query function with the added width and height inputs
226
  text_button.click(query, inputs=[text_prompt, negative_prompt, steps, cfg, method, seed, strength, width, height], outputs=image_output)
227
 
228
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
 
231
  if __name__ == "__main__":