Views
No views yet
requirements.txt1git clone [repository URL]
2cd [repository name]pip install -r requirements.txt1import io
2from PIL import Image
3
4API_URL = "https://api-inference.huggingface.co/models/sarathAI/NFT-Genesis"
5headers = {"Authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
6
7def query(payload):
8 response = requests.post(API_URL, headers=headers, json=payload)
9 return response.content
10
11image_bytes = query({
12 "inputs": "Formula 1 car",
13})
14
15# Added: Check if the response is indeed image bytes
16if image_bytes.startswith(b'\xff\xd8'): # JPEG
17 print("JPEG image detected")
18elif image_bytes.startswith(b'\x89PNG\r\n\x1a\n'): # PNG
19 print("PNG image detected")
20else:
21 print("The response might not be an image or is in an unrecognized format.")
22
23# Attempt to open the image
24try:
25 image = Image.open(io.BytesIO(image_bytes))
26 image.save("output_image.jpg")
27 print("Image saved as output_image.jpg. Please open this file to view the image.")
28except IOError:
29 print("Cannot open the image. The file might be corrupted or in an unsupported format.")
30
31config.py file to tweak performance and output quality.dataset/README.md.CONTRIBUTING.md for submitting pull requests or reporting issues.