Update app.py
Browse files
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 |
-
|
| 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 |
-
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()
|