Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.py 启动程序里的参数musetalk里的 --avatar_id 这个角色id是否可以 在前台动态能否修改而不需要 重新启动服务器?应该怎么做 #341

Open
anstonjie opened this issue Dec 25, 2024 · 7 comments

Comments

@anstonjie
Copy link

程序里的这个参数 parser.add_argument('--avatar_id', type=str, default='avator_1') 参数 --avatar_id 是否可以动态传递,就是前台可以修改这个参数 而不需要重新启动服务器

@anstonjie
Copy link
Author

你好大佬 把你的代码加入以后 下面的 nerfreals[sessionid].change_avatar(new_avatar) 这个方法找不到,我看你引入了

elif opt.model == 'musetalk':
from musereal import MuseReal, load_model, load_avatar, warm_up,change_avatar
但是 musereal 这个类里面也没有这个方法change_avatar 请指导谢谢

async def change_avatar_handler(request):
params = await request.json()
sessionid = params.get('sessionid', 0)
new_avatar_id = params.get('avatar_id')
print('new_avatar_id>>>>>',new_avatar_id)
if sessionid in nerfreals and new_avatar_id:
new_avatar = load_avatar(new_avatar_id)
nerfreals[sessionid].change_avatar(new_avatar)
return web.Response(
content_type="application/json",
text=json.dumps({"code": 0, "data": "Avatar changed successfully"})
)
else:
return web.Response(
content_type="application/json",
text=json.dumps({"code": -1, "data": "Invalid session or avatar ID"})
)

@JACKYLUO1991
Copy link

@anstonjie LipReal类中添加方法如下:
def change_avatar(self, avatar):
self.frame_list_cycle, self.face_list_cycle, self.coord_list_cycle = avatar
# 当切换数字人形象时,旧形象相关的帧数据不再有用
while not self.res_frame_queue.empty():
try:
self.res_frame_queue.get_nowait()
except queue.Empty:
break
logger.info('数字人形象切换完成')

@anstonjie
Copy link
Author

anstonjie commented Dec 30, 2024 via email

@anstonjie
Copy link
Author

def change_avatar(self, avatar):
self.frame_list_cycle, self.face_list_cycle, self.coord_list_cycle = avatar

当切换数字人形象时,旧形象相关的帧数据不再有用

while not self.res_frame_queue.empty():
try:
self.res_frame_queue.get_nowait()
except queue.Empty:
break
print('数字人形象切换完成')

我把方法加入

报错为

ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
File "D:\ai3\LiveTalking.venv\lib\site-packages\aiohttp\web_protocol.py", line 480, in _handle_request
resp = await request_handler(request)
File "D:\ai3\LiveTalking.venv\lib\site-packages\aiohttp\web_app.py", line 569, in _handle
return await handler(request)
File "D:\ai3\LiveTalking\app-two.py", line 244, in change_avatar_handler
nerfreals[sessionid].change_avatar(new_avatar)
File "D:\ai3\LiveTalking\musereal.py", line 256, in change_avatar
self.frame_list_cycle, self.face_list_cycle, self.coord_list_cycle = avatar
ValueError: too many values to unpack (expected 3)
sleep qsize= 127

@bigai-wwb
Copy link

兄弟,我按照你这样改完,人可以切换过去了,,,但是嘴巴的渲染还是前一个形象的

@anstonjie
Copy link
Author

anstonjie commented Jan 7, 2025 via email

@JACKYLUO1991
Copy link

JACKYLUO1991 commented Jan 7, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@JACKYLUO1991 @anstonjie @bigai-wwb and others