cutycat2000x commited on
Commit
2aee8ba
·
verified ·
1 Parent(s): 55e04ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -94
app.py CHANGED
@@ -1,99 +1,38 @@
1
  import gradio as gr
2
- import requests
3
- import json
4
- from PIL import Image
5
- import io
6
- import base64
7
 
8
- API_URL = "https://genv01.plutovid.com/get_image"
9
- COUNT_URL = "https://genv01.plutovid.com/get_image_count"
10
-
11
- def get_total_generated_count():
12
- try:
13
- response = requests.get(COUNT_URL)
14
- response.raise_for_status()
15
- return f"Total Images Generated So Far: {response.json().get('count', 0)}"
16
- except requests.exceptions.RequestException:
17
- return "Could not fetch generation count."
18
-
19
- def generate_from_hosted_api(prompt, progress=gr.Progress(track_tqdm=True)):
20
- if not prompt:
21
- raise gr.Error("Prompt cannot be empty.")
22
-
23
- images = []
24
-
25
- try:
26
- response = requests.get(API_URL, params={'message': prompt}, stream=True)
27
- response.raise_for_status()
28
-
29
- for line in response.iter_lines():
30
- if line:
31
- decoded_line = line.decode('utf-8')
32
- if decoded_line.startswith('event: status'):
33
- pass
34
- elif decoded_line.startswith('data:'):
35
- try:
36
- data_json = json.loads(decoded_line[len('data:'):])
37
- if 'message' in data_json:
38
- progress(0.5, desc=data_json['message'])
39
- elif 'images' in data_json:
40
- progress(0.9, desc="Decoding images...")
41
- for b64_image in data_json['images']:
42
- img_data = base64.b64decode(b64_image)
43
- img = Image.open(io.BytesIO(img_data))
44
- images.append(img)
45
- except json.JSONDecodeError:
46
- pass
47
-
48
- except requests.exceptions.RequestException as e:
49
- raise gr.Error(f"Failed to connect to the generation service: {e}")
50
-
51
- if not images:
52
- return None, "Generation failed or no images were returned."
53
-
54
- return images, "Generation complete!"
55
-
56
-
57
- title = "PlutoGen V0.1"
58
- description = """
59
- # Welcome to PlutoGen V0.1
60
-
61
- **Crafting Realistic and Non-Detectable AI Content**
62
-
63
- This is the first model to be released open-source in the near future by **[PlutoLabs](https://huggingface.co/plutolabs)**, a non-profit from Russia dedicated to keeping pace with current technology. Our goal with PlutoGen is to push the boundaries of AI content generation, making it virtually indistinguishable from human-created content.
64
-
65
- While this very first version may not seem like much, it's a step towards infinite possibilities. If you like this project, please consider leaving a like or following our organization for future releases and the upcoming open-source release of v0.1!
66
-
67
- This model is currently running on an RTX 3090, but outperforms other state of the art models by generating an image in 14 seconds on an RTX 3060.
68
-
69
- Enter a prompt below to see what PlutoGen can do.
70
- """
71
-
72
- with gr.Blocks(theme='soft') as demo:
73
- gr.Markdown(f"<h1 style='text-align: center;'>{title}</h1>")
74
- gr.Markdown(description)
75
-
76
- with gr.Row():
77
- total_count_output = gr.Textbox(label="Generation Stats", interactive=False)
78
-
79
- with gr.Row():
80
- with gr.Column(scale=2):
81
- prompt_input = gr.Textbox(label="Prompt", placeholder="e.g., a photorealistic portrait of a cat wearing a tiny hat")
82
- submit_button = gr.Button("Generate Images", variant="primary")
83
- status_output = gr.Textbox(label="Status", interactive=False)
84
- with gr.Column(scale=3):
85
- image_output = gr.Gallery(label="Generated Images", columns=2, height="auto")
86
-
87
- submit_button.click(
88
- fn=generate_from_hosted_api,
89
- inputs=[prompt_input],
90
- outputs=[image_output, status_output]
91
- ).then(
92
- fn=get_total_generated_count,
93
- outputs=total_count_output
94
- )
95
-
96
- demo.load(get_total_generated_count, None, total_count_output)
97
 
98
  if __name__ == "__main__":
99
  demo.launch()
 
1
  import gradio as gr
 
 
 
 
 
2
 
3
+ with gr.Blocks(theme='soft', css="""
4
+ body {
5
+ display: flex;
6
+ justify-content: center;
7
+ align-items: center;
8
+ height: 100vh;
9
+ }
10
+ .center-text {
11
+ text-align: center;
12
+ color: white;
13
+ }
14
+ .center-text h1 {
15
+ font-size: 4rem;
16
+ font-weight: 900;
17
+ margin-bottom: 1rem;
18
+ }
19
+ .center-text p {
20
+ font-size: 1.5rem;
21
+ margin-bottom: 2rem;
22
+ }
23
+ .center-text a {
24
+ color: #a855f7;
25
+ text-decoration: underline;
26
+ font-size: 1.5rem;
27
+ }
28
+ """) as demo:
29
+ gr.HTML("""
30
+ <div class="center-text">
31
+ <h1>Development Paused</h1>
32
+ <p>We've paused development on this demo to focus on our main open-source release of Pluto1.</p>
33
+ <p>Please visit <a href="https://plutovid.com" target="_blank">plutovid.com</a> for the latest updates.</p>
34
+ </div>
35
+ """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  if __name__ == "__main__":
38
  demo.launch()