Pranjal commited on
Commit ·
9c40d56
1
Parent(s): 6a58cab
add gradio app
Browse files- WARP.md +97 -0
- __pycache__/app.cpython-312.pyc +0 -0
- test_app.py +19 -0
WARP.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# WARP.md
|
| 2 |
+
|
| 3 |
+
This file provides guidance to WARP (warp.dev) when working with code in this repository.
|
| 4 |
+
|
| 5 |
+
## Project Overview
|
| 6 |
+
|
| 7 |
+
This is a Hugging Face Space configured to run a Gradio application. The space is designed to host a small model demo.
|
| 8 |
+
|
| 9 |
+
**Key Information:**
|
| 10 |
+
- **Platform**: Hugging Face Spaces
|
| 11 |
+
- **SDK**: Gradio 5.49.1
|
| 12 |
+
- **Entry Point**: `app.py` (to be created)
|
| 13 |
+
- **License**: Apache 2.0
|
| 14 |
+
- **Remote**: https://huggingface.co/spaces/pranjal00/trial
|
| 15 |
+
|
| 16 |
+
## Architecture
|
| 17 |
+
|
| 18 |
+
Hugging Face Spaces with Gradio follow this pattern:
|
| 19 |
+
- `app.py` contains the Gradio interface definition and launches the app
|
| 20 |
+
- Model files (`.bin`, `.pt`, `.pth`, `.safetensors`, etc.) are tracked with Git LFS
|
| 21 |
+
- The Space automatically runs `app.py` when deployed
|
| 22 |
+
|
| 23 |
+
## Common Commands
|
| 24 |
+
|
| 25 |
+
### Development
|
| 26 |
+
```bash
|
| 27 |
+
# Install Gradio locally
|
| 28 |
+
pip install gradio==5.49.1
|
| 29 |
+
|
| 30 |
+
# Run the app locally
|
| 31 |
+
python app.py
|
| 32 |
+
|
| 33 |
+
# Run with hot reload (if using gradio.reload)
|
| 34 |
+
gradio app.py
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### Deployment
|
| 38 |
+
Changes pushed to the `main` branch are automatically deployed to Hugging Face Spaces. No manual deployment command is needed.
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
# Push to deploy
|
| 42 |
+
git push origin main
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Working with Large Files (LFS)
|
| 46 |
+
This repository uses Git LFS for model files and large binary assets.
|
| 47 |
+
|
| 48 |
+
```bash
|
| 49 |
+
# Track a new large file type
|
| 50 |
+
git lfs track "*.extension"
|
| 51 |
+
|
| 52 |
+
# Verify LFS tracking
|
| 53 |
+
git lfs ls-files
|
| 54 |
+
|
| 55 |
+
# Push LFS files
|
| 56 |
+
git lfs push origin main
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Important Notes
|
| 60 |
+
|
| 61 |
+
### Git LFS Configuration
|
| 62 |
+
The `.gitattributes` file is pre-configured to track common ML file formats with LFS including:
|
| 63 |
+
- Model weights: `*.bin`, `*.pt`, `*.pth`, `*.safetensors`, `*.onnx`
|
| 64 |
+
- Data files: `*.parquet`, `*.arrow`, `*.pkl`, `*.h5`
|
| 65 |
+
- Archives: `*.zip`, `*.tar`, `*.gz`
|
| 66 |
+
|
| 67 |
+
Any new model or large binary files matching these patterns will automatically be tracked with LFS.
|
| 68 |
+
|
| 69 |
+
### Gradio App Structure
|
| 70 |
+
When creating `app.py`, use this pattern:
|
| 71 |
+
```python
|
| 72 |
+
import gradio as gr
|
| 73 |
+
|
| 74 |
+
def your_function(input):
|
| 75 |
+
# Your logic here
|
| 76 |
+
return output
|
| 77 |
+
|
| 78 |
+
demo = gr.Interface(
|
| 79 |
+
fn=your_function,
|
| 80 |
+
inputs=...,
|
| 81 |
+
outputs=...,
|
| 82 |
+
title="...",
|
| 83 |
+
description="..."
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
if __name__ == "__main__":
|
| 87 |
+
demo.launch()
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Space Configuration
|
| 91 |
+
The README.md frontmatter controls Space settings. Key fields:
|
| 92 |
+
- `sdk`: Must match installed Gradio version
|
| 93 |
+
- `app_file`: Entry point (default: `app.py`)
|
| 94 |
+
- `sdk_version`: Gradio version to use
|
| 95 |
+
- `pinned`: Whether Space appears in your profile
|
| 96 |
+
|
| 97 |
+
Modify these in the README.md YAML frontmatter, not in code.
|
__pycache__/app.cpython-312.pyc
ADDED
|
Binary file (458 Bytes). View file
|
|
|
test_app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import unittest
|
| 2 |
+
from app import greet
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class TestGreet(unittest.TestCase):
|
| 6 |
+
def test_greet_returns_hello_with_name(self):
|
| 7 |
+
"""Test that greet function returns 'Hello [name]!!' for a given name."""
|
| 8 |
+
result = greet("Alice")
|
| 9 |
+
self.assertEqual(result, "Hello Alice!!")
|
| 10 |
+
|
| 11 |
+
result = greet("Bob")
|
| 12 |
+
self.assertEqual(result, "Hello Bob!!")
|
| 13 |
+
|
| 14 |
+
result = greet("World")
|
| 15 |
+
self.assertEqual(result, "Hello World!!")
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
unittest.main()
|