Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
URL = "http://127.0.0.1:8188/prompt"
|
| 7 |
+
|
| 8 |
+
def get_latest_image(folder):
|
| 9 |
+
files = os.listdir(folder)
|
| 10 |
+
image_files = [f for f in files if f.lower().endswith(('.png','.jpg','.jpeg'))]
|
| 11 |
+
|
| 12 |
+
def start_queue(prompt_workflow):
|
| 13 |
+
p = {"prompt": prompt_workflow}
|
| 14 |
+
data = json.dumps(p).encode('utf-8')
|
| 15 |
+
requests.post(URL, data=data)
|
| 16 |
+
|
| 17 |
+
def generate_image():
|
| 18 |
+
with open("/home/ec2-user/SageMaker/truss-examples/comfyui-truss/data/comfy_ui_workflow.json", "r") as file_json:
|
| 19 |
+
prompt = json.load(file_json)
|
| 20 |
+
start_queue(prompt)
|
| 21 |
+
|
| 22 |
+
demo = gr.Interface(fn = generate_image, inputs = [], outputs = ["image"])
|
| 23 |
+
demo. launch()
|