akazmi commited on
Commit
7ae7337
·
verified ·
1 Parent(s): 410e9d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -1,8 +1,16 @@
1
  from transformers import pipeline
 
2
 
3
- # Load a pre-trained model
4
- generator = pipeline('image-generation', model='huggingface/gan-model')
 
5
 
6
- # Generate an image
 
 
 
 
7
  generated_image = generator("A futuristic city")
8
- generated_image[0]['image'].show() # Show the generated image
 
 
 
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()