uniquenihal/Assignment1b
0
Assignment 1B Hugging Face Space
This repo now includes a minimal Hugging Face Space demo for stabilityai/sd-turbo and a reusable Python program that generates the required image prompt:
A cute cat sitting on a rainbow.
Files
app.py: Gradio Space UI with anOverviewtab and a separatePart Btabsrc/assignement1b/generator.py: shared SD Turbo loading and image generation logicsrc/assignement1b/__init__.py: simple CLI entry point that savescat_rainbow.pngrequirements.txt: Space dependencies
What the Python program does
It:
- Loads the Hugging Face
stabilityai/sd-turbomodel. - Generates an image from the prompt
A cute cat sitting on a rainbow. - Saves the image as
cat_rainbow.png.
Local run
Install dependencies yourself, then run either option:
Run the Python script
PYTHONPATH=src python3 -m assignement1bThat generates cat_rainbow.png in the project root.
Run the Space UI locally
python3 app.pyHugging Face Space setup
Use a Gradio Space and push these files into it. The YAML block at the top of this README is already formatted for Hugging Face Spaces.
Important compatibility note:
- This repo pins
gradio==6.24.0because older Gradio versions can fail on Spaces with newerhuggingface_hubreleases.
Recommended Space settings:
- SDK:
gradio - Hardware: GPU recommended for
sd-turbo - Python: 3.10+
If you want to create the Space with the Hugging Face CLI flow referenced by https://huggingface.co/new-space/agents.md, the rough steps are:
hf --version
hf auth loginThen create a new Gradio Space and upload this repo content.
Notes
- The code uses
num_inference_steps=1, which matches SD Turbo's low-latency use case. - On GPU it loads the fp16 variant automatically.
- On CPU it falls back to fp32, but generation will be slower.
