akazmi commited on
Commit
494f2fa
·
verified ·
1 Parent(s): 7ae7337

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -1,16 +1,17 @@
1
  from transformers import pipeline
2
- from huggingface_hub import login
3
 
4
- # Login to Hugging Face with your API key
5
- api_key = 'your-huggingface-api-key'
6
- login(token=api_key)
7
 
8
- # Initialize the pipeline with a correct model identifier
9
- # Here I'm using a popular image generation model like 'stable-diffusion'
10
- generator = pipeline('image-generation', model='CompVis/stable-diffusion-v1-4-original', use_auth_token=api_key)
 
 
 
11
 
12
- # Generate an image from a text prompt
13
- generated_image = generator("A futuristic city")
14
 
15
- # Show the generated image
16
- generated_image[0]['image'].show()
 
1
  from transformers import pipeline
 
2
 
3
+ # Define your API key
4
+ api_key = "your_huggingface_api_key"
 
5
 
6
+ # Initialize the pipeline using the API key
7
+ generator = pipeline(
8
+ "image-generation",
9
+ model="CompVis/stable-diffusion-v1-4-original",
10
+ use_auth_token=api_key
11
+ )
12
 
13
+ # Generate an image
14
+ result = generator("A futuristic city")
15
 
16
+ # Display the generated image
17
+ result[0]["image"].show()