Master0fNone commited on
Commit
0b9246a
·
verified ·
1 Parent(s): 4d272f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,10 +1,32 @@
1
  import gradio as gr
 
2
 
 
 
 
 
 
3
  with gr.Blocks(fill_height=True) as demo:
4
  with gr.Sidebar():
5
  gr.Markdown("# Inference Provider")
6
  gr.Markdown("This Space showcases the black-forest-labs/FLUX.1-dev model, served by the nebius API. Sign in with your Hugging Face account to use this API.")
7
- button = gr.LoginButton("Sign in")
8
- gr.load("models/black-forest-labs/FLUX.1-dev", accept_token=button, provider="nebius")
9
-
10
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from huggingface_hub import login
3
 
4
+ # A function to handle Hugging Face login (authentication)
5
+ def authenticate_user(token):
6
+ login(token) # This will authenticate using the provided Hugging Face token
7
+
8
+ # Create the Gradio Blocks interface
9
  with gr.Blocks(fill_height=True) as demo:
10
  with gr.Sidebar():
11
  gr.Markdown("# Inference Provider")
12
  gr.Markdown("This Space showcases the black-forest-labs/FLUX.1-dev model, served by the nebius API. Sign in with your Hugging Face account to use this API.")
13
+
14
+ # Textbox for user to input Hugging Face token
15
+ token_input = gr.Textbox(label="Hugging Face Token", type="password")
16
+ button = gr.Button("Sign in")
17
+
18
+ # The button action triggers authentication
19
+ button.click(authenticate_user, inputs=token_input, outputs=None)
20
+
21
+ # Assuming you want to load the model into the Gradio interface after authentication
22
+ def inference_function(input_text):
23
+ # Add your model inference logic here
24
+ # Example: interact with Hugging Face model API using authenticated token
25
+ from transformers import pipeline
26
+ model = pipeline("text-generation", model="black-forest-labs/FLUX.1-dev")
27
+ return model(input_text)
28
+
29
+ # Create the main interface
30
+ gr.Interface(fn=inference_function, inputs="text", outputs="text").launch()
31
+
32
+ demo.launch()