sarathAI commited on
Commit
8abd3e5
1 Parent(s): 04e621f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -6
README.md CHANGED
@@ -39,13 +39,38 @@ This project involves a text-to-image model fine-tuned on the Stable Diffusion 1
39
 
40
  ## Usage
41
  To generate an image:
42
- ```python
43
- from model import NFTGenesisModel
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- model = NFTGenesisModel()
46
- description = "Your textual description here"
47
- image = model.generate(description)
48
- image.save("output.jpg")
49
  ```
50
 
51
  ## Configuration
 
39
 
40
  ## Usage
41
  To generate an image:
42
+ ```import requests
43
+ import io
44
+ from PIL import Image
45
+
46
+ API_URL = "https://api-inference.huggingface.co/models/sarathAI/NFT-Genesis"
47
+ headers = {"Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
48
+
49
+ def query(payload):
50
+ response = requests.post(API_URL, headers=headers, json=payload)
51
+ return response.content
52
+
53
+ image_bytes = query({
54
+ "inputs": "Formula 1 car",
55
+ })
56
+
57
+ # Added: Check if the response is indeed image bytes
58
+ if image_bytes.startswith(b'\xff\xd8'): # JPEG
59
+ print("JPEG image detected")
60
+ elif image_bytes.startswith(b'\x89PNG\r\n\x1a\n'): # PNG
61
+ print("PNG image detected")
62
+ else:
63
+ print("The response might not be an image or is in an unrecognized format.")
64
+
65
+ # Attempt to open the image
66
+ try:
67
+ image = Image.open(io.BytesIO(image_bytes))
68
+ image.save("output_image.jpg")
69
+ print("Image saved as output_image.jpg. Please open this file to view the image.")
70
+ except IOError:
71
+ print("Cannot open the image. The file might be corrupted or in an unsupported format.")
72
+
73
 
 
 
 
 
74
  ```
75
 
76
  ## Configuration