Spaces:
Sleeping
Sleeping
nero7151 commited on
Commit ·
d4a5b3f
1
Parent(s): 857ab4f
\fastapi_gpt2_space 삭제
Browse files
fastapi_gpt2_space/Dockerfile
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
FROM python:3.10
|
| 2 |
-
|
| 3 |
-
WORKDIR /app
|
| 4 |
-
|
| 5 |
-
COPY . /app
|
| 6 |
-
|
| 7 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 8 |
-
|
| 9 |
-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastapi_gpt2_space/app/main.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
from fastapi import FastAPI, Request
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
|
| 4 |
-
print("✅ FastAPI 시작됨!")
|
| 5 |
-
|
| 6 |
-
app = FastAPI()
|
| 7 |
-
|
| 8 |
-
print("📦 모델 로딩 시작")
|
| 9 |
-
generator = pipeline("text-generation", model="gpt2")
|
| 10 |
-
print("✅ 모델 로딩 완료!")
|
| 11 |
-
|
| 12 |
-
@app.get("/")
|
| 13 |
-
def root():
|
| 14 |
-
return {"message": "✅ FastAPI 정상 작동 중!"}
|
| 15 |
-
|
| 16 |
-
@app.post("/generate")
|
| 17 |
-
async def generate_text(request: Request):
|
| 18 |
-
body = await request.json()
|
| 19 |
-
prompt = body.get("prompt", "")
|
| 20 |
-
print(f"📥 프롬프트 입력: {prompt}")
|
| 21 |
-
if not prompt:
|
| 22 |
-
return {"error": "Missing 'prompt' field"}
|
| 23 |
-
|
| 24 |
-
result = generator(prompt, max_length=50, do_sample=True)
|
| 25 |
-
return {"generated_text": result[0]["generated_text"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastapi_gpt2_space/requirements.txt
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
fastapi
|
| 2 |
-
uvicorn[standard]
|
| 3 |
-
transformers
|
| 4 |
-
torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|