chansung commited on
Commit
df18ce5
Β·
1 Parent(s): 4f44913

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -1
app.py CHANGED
@@ -58,6 +58,22 @@ demoInterface = gr.Interface(
58
  def welcome(name):
59
  return f"Welcome to Gradio, {name}!"
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  with gr.Blocks() as demo:
62
  gr.Markdown(
63
  """
@@ -93,11 +109,45 @@ with gr.Blocks() as demo:
93
  btn = gr.Button(value="Ready to Deploy!")
94
  # btn.click(mirror, inputs=[im], outputs=[im_2])
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  with gr.Blocks() as demo2:
97
  gr.Markdown(
98
  """
99
  # Your own Stable Diffusion on Hugging Face πŸ€— Endpoint
100
- """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  gr.TabbedInterface(
103
  [demoInterface, demo, demo2], ["Try-out", "πŸš€ Deploy on GCP", " Deploy on πŸ€— Endpoint"]
 
58
  def welcome(name):
59
  return f"Welcome to Gradio, {name}!"
60
 
61
+ def avaliable_providers():
62
+ providers = []
63
+
64
+ headers = {
65
+ "Content-Type": "application/json",
66
+ }
67
+ endpoint_url = "https://api.endpoints.huggingface.cloud/provider"
68
+ response = requests.get(endpoint_url, headers=headers)
69
+
70
+ for provider in response.json()['items']:
71
+ if provider['status'] != 'avaliable':
72
+ providers.append(provider['vendor'])
73
+
74
+ return providers
75
+
76
+
77
  with gr.Blocks() as demo:
78
  gr.Markdown(
79
  """
 
109
  btn = gr.Button(value="Ready to Deploy!")
110
  # btn.click(mirror, inputs=[im], outputs=[im_2])
111
 
112
+ selected_provider = None
113
+ provider_selector = None
114
+ avalialbe_regions = []
115
+
116
+ def avaliable_regions(provider):
117
+ avalialbe_regions = []
118
+
119
+ headers = {
120
+ "Content-Type": "application/json",
121
+ }
122
+ endpoint_url = "https://api.endpoints.huggingface.cloud/region"
123
+ response = requests.get(endpoint_url, headers=headers)
124
+
125
+ for region in response.json()['items']:
126
+ if region['status'] != 'avaliable':
127
+ avalialbe_regions.append(region['vendor'])
128
+
129
  with gr.Blocks() as demo2:
130
  gr.Markdown(
131
  """
132
  # Your own Stable Diffusion on Hugging Face πŸ€— Endpoint
133
+ """)
134
+
135
+ providers = avaliable_providers()
136
+
137
+ with gr.Row():
138
+ provider_selector = gr.Dropdown(
139
+ label="select cloud provider",
140
+ interactive=True,
141
+ choices=providers
142
+ )
143
+ provider_selector.change(avaliable_regions)
144
+
145
+ region_selector = gr.Dropdown(
146
+ avalialbe_regions,
147
+ value="us-central1",
148
+ interactive=True,
149
+ label="reegions"
150
+ )
151
 
152
  gr.TabbedInterface(
153
  [demoInterface, demo, demo2], ["Try-out", "πŸš€ Deploy on GCP", " Deploy on πŸ€— Endpoint"]