besarismaili commited on
Commit
1d1f8b7
·
1 Parent(s): 2bce580

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -23
app.py CHANGED
@@ -1,31 +1,23 @@
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(dummy_input):
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
- return "Done"
29
 
30
- iface = gr.Interface(fn=wrapper_func, inputs='text', outputs='text')
31
- iface.launch()
 
 
1
+ #@title Connect to the Stability API
2
+
3
  from stability_sdk.api import Context
4
  from stability_sdk.animation_ui import create_ui
 
 
 
5
 
6
+ # @markdown To get your API key visit https://dreamstudio.ai/account
7
+ STABILITY_HOST = "grpc.stability.ai:443" #@param {type:"string"}
 
8
 
9
+ # Connect to Stability API
10
+ context = Context(STABILITY_HOST, STABILITY_KEY)
 
11
 
12
+ # Test the connection
13
+ context.get_user_info()
14
+ print("Connection successful!")
15
 
16
+ #@title Animation UI
17
+ show_ui_in_notebook = True #@param {type:"boolean"}
 
18
 
19
+ outputs_path = r'C:\Work\tst\SAnim'
 
 
 
 
 
20
 
21
+ ui = create_ui(context, outputs_path)
22
+ ui.queue(concurrency_count=2, max_size=2)
23
+ ui.launch(show_api=False, debug=True, inline=show_ui_in_notebook, height=768, share=True, show_error=True)