Issues with SadTalker ZeroGPU Spaces + Inquiry About Community Grant

Hi Hugging Face Team,

I hope you’re doing well!

I’ve been using two Spaces that run on the ZerGPU tier, but unfortunately, neither of them seems to be working correctly. They don’t generate images as expected and it gives me errors for outputs. The Spaces are:

  • abreza/SadTalker
  • Han-123/SadTalker

I’d really appreciate any help in getting them to function properly.

Also, I applied for the Community Grant for ZeroGPU but haven’t received any response yet. I really need access to it for my studies and work, and having it for free would be a huge help. Could you kindly provide some guidance on how the approval process works or what I might be missing?

Looking forward to your response!

Thanks a lot for your time and support.

Best regards,
Hebatullah Hesham

1 Like

I’ll try to debug it myself later when I have some free time, but I think it probably worked when the author of the space created it.
Recently, the specifications for the Zero GPU space changed drastically, and there are still some bugs that occurred at that time, so maybe that’s why it doesn’t work. There are many such spaces.
If you could report that it doesn’t work in one of the Discussions below or in the New Discussion, I think that would help speed up the resolution.

I think the following post about community grant may be helpful.

Well, I decided to debug it, and when I copied the space, it worked normally even though I did not do anything.
I guess it was because I hadn’t restarted the space after the HF-wide Zero GPU space refurbishment in the summer.
But there’s no way to reboot it from the outside… if there was, anyone could use it for mischief.

@not-lain @victor There are probably quite a few Zero GPU spaces throughout HF that are up and running but not actually working anymore.
Any idea of a mechanism or personnel that could force a restart on a wide range of spaces from the HF side?

Is this means I have recived the ZeroGPU Grant?

1 Like

I’ve never applied for a community grant so I don’t know…
But I’ve never seen the screen I’m on, so probably yes.

Edit:
Sorry. I heard it wasn’t right.

1 Like

do you know how to get approved for this community grant?

I don’t know anything about it at all.

P.S.
@not-lain What are community grants actually like now?

1 Like

Hi @Hebatullah
I have cloned the space in my personal account, and without changing anything it worked perfectly, SadTalker - a Hugging Face Space by not-lain
I will delete the space in a while (no idea when), feel free to use it in the meantime.
No clue why their spaces stopped functioning, maybe some memory overflow or something, but if this would ever happen in my space feel free to open a discussion there and let me know and i’ll investigate the issue.

As for SadTalker , the model is small enough to run locally, the only things you need to change to make it run on your local PC are remove the following

- import spaces
(...)
- @spaces.GPU
(...) 

you can keep the rest as is and it should work for you.

For Zero GPU access, I am not an admin so I have no say in this, the access to the organization was given at the earlier days for people for beta access and for feedback and to support some people, but since the feature is now stable for development they have stopped accespting requests lately, your best bet is to

  • apply to join the organization and wait
    • apply for a gpu grant and wait
  • access pro (9$/month) which comes with 10 zero gpu spaces IIRC

Feel free to join the HF discord server and ping me or post your questions there if you have any, we have a pretty active community there.

Best of luck with your studies and wishing you all the best :four_leaf_clover:

Regards
Hafedh Hichri (Lain)

2 Likes

Hebatullah

1h

Do I clone this space to my device and delete this section?

  • import spaces
    (…)
  • @spaces.GPU
    (…)

In which file is this section located?

1 Like

Thanks for the explanation.

apply to join the organization and wait

Huh? I’ve never heard of this, but do we get Zero GPU space if we belong to org?

apply for a gpu grant and wait

Is that procedure the one that is in the manual?
I’m sure I’ve got it somewhere…

Not that it matters, but in HF, the manuals that are automatically generated from the code are up-to-date, but the parts where the code is closed, such as server-side spec changes, GUI changes, and many other parts are lacking manuals. I enjoy the many hidden features, but they are inconvenient.

HF Discord

Join from here.

Code for ZeroGPU Space compatible CPU Space

It’s a little uncool, but if you remove import spaces and instead write this code at the beginning of your code, you can go back and forth between Zero GPU space and CPU space without any changes. (if everything else is ok).

import os
if os.environ.get("SPACES_ZERO_GPU") is not None:
    import spaces
else:
    class spaces:
        @staticmethod
        def GPU(func):
            def wrapper(*args, **kwargs):
                return func(*args, **kwargs)
            return wrapper

@spaces.GPU
def fake_gpu():
  pass
2 Likes

In which file is this section located?

Maybe in app.py.

1 Like

Hi @Hebatullah

Do I clone this space to my device and delete this section?

yes, you can download the files in that space in your PC and delete those 2 lines.

you will find them in a file called app.py, they are not near each other, so look for them and delete them.
Once you have done that, you can run your app like any normal python file and it will tell you where you can access your local host, open that url in your browser and you’re all set.

2 Likes

the organization is in zero-gpu-explorers (ZeroGPU Explorers)

In any of your spaces go to settings and you will find it on the left, see picture below

didn’t try the code in this section but it looks solid from a first look, thanks for sharing this, I will consider this method in the future

2 Likes

the organization is in zero-gpu-explorers (ZeroGPU Explorers)

Thank you. I had thought that there were a lot of people who belonged to this group, but it had some obvious advantages.:thinking:
This might be a quicker workaround than a community grant.

see picture below

It’s obvious at a glance.

it looks solid from a first look

The base of this code is the one in the crunch clause, and it has a proven track record of working, so I guess I’m okay with it. And it’s not like we’re doing anything difficult.

2 Likes

What are the device specifications that Sad Talker can run on? Will these specifications run Sad Talker + how long will it take to make one 12 second video?
1

I have cloned your space do you mean deleteing these excalty? Is this the section I supposed to delete exactly from from line 6 to line 35?:

import spaces
import torch
import gradio as gr
from huggingface_hub import snapshot_download

from examples.get_examples import get_examples
from src.facerender.pirender_animate import AnimateFromCoeff_PIRender
from src.utils.preprocess import CropAndExtract
from src.test_audio2coeff import Audio2Coeff
from src.facerender.animate import AnimateFromCoeff
from src.generate_batch import get_data
from src.generate_facerender_batch import get_facerender_data
from src.utils.init_path import init_path

checkpoint_path = ‘checkpoints’
config_path = ‘src/config’
device = “cuda” if torch.cuda.is_available(
) else “mps” if platform.system() == ‘Darwin’ else “cpu”

os.environ[‘TORCH_HOME’] = checkpoint_path
snapshot_download(repo_id=‘vinthony/SadTalker-V002rc’,
local_dir=checkpoint_path, local_dir_use_symlinks=True)

def mp3_to_wav(mp3_filename, wav_filename, frame_rate):
AudioSegment.from_file(file=mp3_filename).set_frame_rate(
frame_rate).export(wav_filename, format=“wav”)

@spaces.GPU(duration=120)
def generate_video(source_image, driven_audio, preprocess=‘crop’, still_mode=False, use_enhancer=False,
batch_size=1, size=256, pose_style=0, facerender=‘facevid2vid’, exp_scale=1.0,
use_ref_video=False, ref_video=None, ref_info=None, use_idle_mode=False,
length_of_audio=0, use_blink=True, result_dir=‘./results/’):
# Initialize models and paths
sadtalker_paths = init_path(
checkpoint_path, config_path, size, False, preprocess)
audio_to_coeff = Audio2Coeff(sadtalker_paths, device)
preprocess_model = CropAndExtract(sadtalker_paths, device)
animate_from_coeff = AnimateFromCoeff(sadtalker_paths, device) if facerender == ‘facevid2vid’ and device != ‘mps’
else AnimateFromCoeff_PIRender(sadtalker_paths, device)

don’t delete from line to line
only delete what I have mentioned above, do not delete what’s between them

1 Like

Ok how to start SadTalker? from the cloned files I didn’t find webui.bat

1 Like

It’s a python file, you can run it as any normal python file, with the exception that it will open a local host for you instead.

you can open your terminal (CMD) and cd into that folder then run the commands OR you can go to the folder that has the app and click on top and write cmd as shown in the picture below

  • first time only (to download the necessary dependencies)
pip install -r reequirements.txt
  • to run the app (everytime you want to start your app )
python app.py
  • now open any browser and go to http://127.0.0.1:7860 (if you ever forget the url it will be shown in your terminal when you start your app )

(base) E:\SadTalker>python app.py
Traceback (most recent call last):
File “E:\SadTalker\app.py”, line 6, in
import spaces
ModuleNotFoundError: No module named ‘spaces’

(base) E:\SadTalker>