Caption generation crashes with "RuntimeError: Numpy is not available" — pin numpy<2

#3
by nootxlm - opened

This Space starts, but caption generation crashes on the first request. The runtime traceback ends with:

File "/home/user/app/llama/model.py", line 409, in forward
    x = [self.clip_transform(img) for img in imgs]
  ...
File ".../torchvision/transforms/functional.py", in to_tensor
    img = torch.from_numpy(np.array(pic, ...))
RuntimeError: Numpy is not available

Cause: requirements.txt pins torch==1.12.0+cu113 but leaves numpy unpinned, so the environment now installs numpy 2.x. Torch 1.12 was built against numpy 1.x and cannot initialise its numpy bridge against numpy 2, which is exactly what "Numpy is not available" reports — numpy is installed, it is just a major version this torch cannot use. Every image transform that goes through to_tensor then fails.

Fix: pin numpy below 2 in requirements.txt, alongside the existing torch pin:

numpy<2

(1.26.x is the last 1.x line and pairs with torch 1.12.)

To check: after a rebuild, torch.from_numpy on a small array should succeed in the Space environment, and caption generation should return a caption instead of the traceback above.

Sign up or log in to comment