Download test_app.py from Afnaan04/GenTex_AI: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/Afnaan04/GenTex_AI/resolve/main/test_app.py
- Command line
-
hf download hf://Afnaan04/GenTex_AI/test_app.py
-
curl -L -o test_app.py https://huggingface.co/Afnaan04/GenTex_AI/resolve/main/test_app.py
1.44 kB
| import requests | |
| import base64 | |
| from PIL import Image | |
| import io | |
| URL = "http://127.0.0.1:5000/generate" | |
| def test_generation(): | |
| print(f"Testing {URL}...") | |
| try: | |
| # Test Wood Texture | |
| payload = { | |
| "texture_type": "wood", | |
| "seed": 42, | |
| "creativity": 1.0 | |
| } | |
| response = requests.post(URL, data=payload) | |
| if response.status_code == 200: | |
| data = response.json() | |
| if "image" in data: | |
| print("✅ Request successful. Image data received.") | |
| # Decode image | |
| img_data = data["image"].split(",")[1] | |
| img_bytes = base64.b64decode(img_data) | |
| img = Image.open(io.BytesIO(img_bytes)) | |
| img.save("test_output.png") | |
| print(f"✅ Image saved to test_output.png (Size: {img.size})") | |
| return True | |
| else: | |
| print("❌ Response missing 'image' field:", data) | |
| else: | |
| print(f"❌ Request failed with status {response.status_code}: {response.text}") | |
| except requests.exceptions.ConnectionError: | |
| print("❌ Could not connect to the server. Is app.py running?") | |
| except Exception as e: | |
| print(f"❌ Error: {e}") | |
| return False | |
| if __name__ == "__main__": | |
| test_generation() | |