kavyabhand commited on
Commit
c70b05c
·
verified ·
1 Parent(s): f66a017

Fix startup crash: AttributeError (gradio-api-drift)

Browse files

Hi! This Space currently fails to start on Hugging Face with:

```
AttributeError: module 'gradio' has no attribute 'inputs'
```

**Cause.** The Space fails on current libraries for two reasons: app.py uses removed Gradio 3 APIs (`gr.inputs.Image`, `gr.outputs.Textbox`), causing `AttributeError: module 'gradio' has no attribute 'inputs'`, and the rebuilt environment pairs Gradio 4.32.1 with a huggingface_hub version that no longer exports `HfFolder`, causing `ImportError: cannot import name 'HfFolder'`. Pinning the dependency era restores the Gradio 4-compatible huggingface_hub, while updating the two component calls restores the original image/text interface.

**Change.** `README.md`, `app.py`, `requirements.txt`. `requirements.txt` is a lockfile resolved as of 2024-06-15 (Python 3.10), so the app runs on the library versions it was written for. `python_version` is pinned in the README to the interpreter we tested with. Nothing else is touched.

**Tested.** We rebuilt the Space with this patch the way Spaces builds it (README front-matter, `requirements.txt`, then the SDK), on 2 vCPU / 16 GB, like cpu-basic. The app started, and calling its `/predict` endpoint returned:

```
'a dog running in the water with a frisbee '
```

The diagnosis and patch were written by [Beam](https://huggingface.co/reflection/Beam-1.0-501B-A23B) (Reflection AI's open model) as part of Space Doctor, a Build with Beam challenge project that repairs broken Spaces and only proposes fixes that pass this check. We read the diff before opening this PR. Feel free to close it if you'd rather fix it another way.

Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +2 -2
  3. requirements.txt +99 -2
README.md CHANGED
@@ -1,4 +1,5 @@
1
  ---
 
2
  title: Image Caption
3
  emoji: 🏅
4
  colorFrom: blue
 
1
  ---
2
+ python_version: "3.10"
3
  title: Image Caption
4
  emoji: 🏅
5
  colorFrom: blue
app.py CHANGED
@@ -22,8 +22,8 @@ def predict(image,max_length=64, num_beams=3):
22
 
23
 
24
 
25
- input = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
26
- output = gr.outputs.Textbox(type="auto",label="Captions")
27
  examples = [f"example{i}.jpg" for i in range(1,7)]
28
 
29
  title = "Image Captioning "
 
22
 
23
 
24
 
25
+ input = gr.Image(label="Upload any Image", type='pil')
26
+ output = gr.Textbox(label="Captions")
27
  examples = [f"example{i}.jpg" for i in range(1,7)]
28
 
29
  title = "Image Captioning "
requirements.txt CHANGED
@@ -1,2 +1,99 @@
1
- transformers
2
- torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.3.0
3
+ annotated-types==0.7.0
4
+ anyio==4.4.0
5
+ attrs==23.2.0
6
+ authlib==1.3.1
7
+ certifi==2024.6.2
8
+ cffi==1.16.0
9
+ charset-normalizer==3.3.2
10
+ click==8.1.7
11
+ contourpy==1.2.1
12
+ cryptography==42.0.8
13
+ cycler==0.12.1
14
+ dnspython==2.6.1
15
+ email-validator==2.1.1
16
+ exceptiongroup==1.2.1
17
+ fastapi==0.111.0
18
+ fastapi-cli==0.0.4
19
+ ffmpy==0.3.2
20
+ filelock==3.15.1
21
+ fonttools==4.53.0
22
+ fsspec==2024.6.0
23
+ gradio==4.32.1
24
+ gradio-client==0.17.0
25
+ h11==0.14.0
26
+ httpcore==1.0.5
27
+ httptools==0.6.1
28
+ httpx==0.27.0
29
+ huggingface-hub==0.23.4
30
+ idna==3.7
31
+ importlib-resources==6.4.0
32
+ itsdangerous==2.2.0
33
+ jinja2==3.1.4
34
+ jsonschema==4.22.0
35
+ jsonschema-specifications==2023.12.1
36
+ kiwisolver==1.4.5
37
+ markdown-it-py==3.0.0
38
+ markupsafe==2.1.5
39
+ matplotlib==3.9.0
40
+ mdurl==0.1.2
41
+ mpmath==1.3.0
42
+ networkx==3.3
43
+ numpy==1.26.4
44
+ nvidia-cublas-cu12==12.1.3.1
45
+ nvidia-cuda-cupti-cu12==12.1.105
46
+ nvidia-cuda-nvrtc-cu12==12.1.105
47
+ nvidia-cuda-runtime-cu12==12.1.105
48
+ nvidia-cudnn-cu12==8.9.2.26
49
+ nvidia-cufft-cu12==11.0.2.54
50
+ nvidia-curand-cu12==10.3.2.106
51
+ nvidia-cusolver-cu12==11.4.5.107
52
+ nvidia-cusparse-cu12==12.1.0.106
53
+ nvidia-nccl-cu12==2.20.5
54
+ nvidia-nvjitlink-cu12==12.5.40
55
+ nvidia-nvtx-cu12==12.1.105
56
+ orjson==3.10.5
57
+ packaging==24.1
58
+ pandas==2.2.2
59
+ pillow==10.3.0
60
+ pycparser==2.22
61
+ pydantic==2.7.4
62
+ pydantic-core==2.18.4
63
+ pydub==0.25.1
64
+ pygments==2.18.0
65
+ pyparsing==3.1.2
66
+ python-dateutil==2.9.0.post0
67
+ python-dotenv==1.0.1
68
+ python-multipart==0.0.9
69
+ pytz==2024.1
70
+ pyyaml==6.0.1
71
+ referencing==0.35.1
72
+ regex==2024.5.15
73
+ requests==2.32.3
74
+ rich==13.7.1
75
+ rpds-py==0.18.1
76
+ ruff==0.4.9
77
+ safetensors==0.4.3
78
+ semantic-version==2.10.0
79
+ shellingham==1.5.4
80
+ six==1.16.0
81
+ sniffio==1.3.1
82
+ starlette==0.37.2
83
+ sympy==1.12.1
84
+ tokenizers==0.19.1
85
+ tomlkit==0.12.0
86
+ toolz==0.12.1
87
+ torch==2.3.1
88
+ tqdm==4.66.4
89
+ transformers==4.41.2
90
+ triton==2.3.1
91
+ typer==0.12.3
92
+ typing-extensions==4.12.2
93
+ tzdata==2024.1
94
+ ujson==5.10.0
95
+ urllib3==2.2.1
96
+ uvicorn==0.30.1
97
+ uvloop==0.19.0
98
+ watchfiles==0.22.0
99
+ websockets==11.0.3