Spaces:
Runtime error
Runtime error
Commit
·
3206b97
1
Parent(s):
3c726e8
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,30 @@
|
|
1 |
-
|
2 |
import getpass
|
3 |
from stability_sdk.api import Context
|
4 |
from stability_sdk.animation_ui import create_ui
|
|
|
5 |
|
6 |
-
|
7 |
-
STABILITY_HOST = "grpc.stability.ai:443" #@param {type:"string"}
|
8 |
-
STABILITY_KEY = ""#getpass.getpass('Enter your API Key')
|
9 |
|
10 |
-
|
11 |
-
|
|
|
12 |
|
13 |
-
# Test the connection
|
14 |
-
context.get_user_info()
|
15 |
-
print("Connection successful!")
|
16 |
|
17 |
-
|
18 |
-
show_ui_in_notebook = True #@param {type:"boolean"}
|
19 |
|
20 |
-
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
import getpass
|
3 |
from stability_sdk.api import Context
|
4 |
from stability_sdk.animation_ui import create_ui
|
5 |
+
import gradio as gr
|
6 |
|
7 |
+
STABILITY_HOST = "grpc.stability.ai:443"
|
|
|
|
|
8 |
|
9 |
+
def connect_to_stability_api(api_key):
|
10 |
+
# Connect to Stability API
|
11 |
+
context = Context(STABILITY_HOST, api_key)
|
12 |
|
13 |
+
# Test the connection
|
14 |
+
context.get_user_info()
|
15 |
+
print("Connection successful!")
|
16 |
|
17 |
+
outputs_path = '/tmp/SAnim' # Hugging Face Spaces only allows writing to the /tmp directory
|
|
|
18 |
|
19 |
+
ui = create_ui(context, outputs_path)
|
20 |
+
ui.queue(concurrency_count=2, max_size=2)
|
21 |
+
ui.launch(show_api=False, debug=True, inline=True, height=768, share=True, show_error=True)
|
22 |
|
23 |
+
def wrapper_func():
|
24 |
+
api_key = os.getenv('STABILITY_KEY')
|
25 |
+
if not api_key:
|
26 |
+
api_key = getpass.getpass('Enter your API Key')
|
27 |
+
connect_to_stability_api(api_key)
|
28 |
+
|
29 |
+
iface = gr.Interface(fn=wrapper_func, inputs=[], outputs=[])
|
30 |
+
iface.launch()
|