CoolFace
Apppublic

uniquenihal/Assignment1b

sourceHugging Faceupdated 1mo agoView on Hugging Face
0likes
App README

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 an Overview tab and a separate Part B tab
  • src/assignement1b/generator.py: shared SD Turbo loading and image generation logic
  • src/assignement1b/__init__.py: simple CLI entry point that saves cat_rainbow.png
  • requirements.txt: Space dependencies

What the Python program does

It:

  1. 1.Loads the Hugging Face stabilityai/sd-turbo model.
  2. 2.Generates an image from the prompt A cute cat sitting on a rainbow.
  3. 3.Saves the image as cat_rainbow.png.

Local run

Install dependencies yourself, then run either option:

Run the Python script

bash
PYTHONPATH=src python3 -m assignement1b

That generates cat_rainbow.png in the project root.

Run the Space UI locally

bash
python3 app.py

Hugging 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.0 because older Gradio versions can fail on Spaces with newer huggingface_hub releases.

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:

bash
hf --version
hf auth login

Then 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.