TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #425 · 20 апр.

Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках. Выглядело это примерно так: from fastapi.concurrency import run_in_threadpool async def execute(data: DataRequest) -> DataResponse: try: result = await run_in_threadpool(sync_function, data) return DataResponse(data=result) except Exception as e: return DataResponse( error=str(e), success=False, ) В общем работает нормально. Для всех вызовов под капотом используется общий тредпул, всё работает предсказуемо. Но потребовалось изменить количество запускаемых в пуле потоков (по умолчанию создается 40 воркеров). Так как дело происходит с FastAPI, делается это через lifespan используя настройки anyio: import anyio @asynccontextmanager async def lifespan(app: FastAPI): limiter = anyio.to_thread.current_default_thread_limiter() limiter.total_tokens = 100 yield # если вдруг нужно вернуть обратно limiter.total_tokens = 40 Зачем менять количество воркеров? - уменьшить, если оперативки мало (один тред занимает ~8мб) - увеличить чтобы выдержать нагрузку Если есть предложения получше при тех же вводных - предлагайте😉 #async

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #noaifraudact

当前筛选 #noaifraudact清除筛选
AI & Law

@ai_and_law · Post #241 · 15.02.2024 г., 08:04

US Lawmakers Introduce No AI FRAUD Act Hello everyone! US lawmakers María Elvira Salazar and Madeleine Dean introduced the No Artificial Intelligence Fake Replicas And Unauthorized Duplications (No AI FRAUD) Act on January 10, aiming to safeguard individuals' likeness and voice from exploitation in AI-generated content. The bill addresses concerns over the misuse of personalized generative AI cloning models, which enable human impersonation and unauthorized creation of fakes using others' images and voices. It seeks to protect the personal rights of individuals, including musical artists, actors, athletes, and even students, whose likeness and voice have been violated. Examples cited include AI-generated songs featuring famous artists like Drake and The Weeknd, false endorsements using celebrities like Tom Hanks, and the creation of non-consensual and intimate deepfakes, particularly concerning high school girls in a New Jersey town. Under the No AI FRAUD Act, individuals gain federal intellectual property (IP) rights over their likeness and voice, empowering them to enforce these rights against those responsible for creating, facilitating, or disseminating AI-generated content without their consent. The bill aims to curb the proliferation of AI-generated imitations and deepfakes while protecting individuals' rights and privacy. #NoAIFRAUDAct#AIPolicy#IntellectualProperty