difarft commited on
Commit
ea8d5c0
·
verified ·
1 Parent(s): b22cfd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -5,16 +5,17 @@ from PIL import Image
5
  import io
6
  from contextlib import asynccontextmanager
7
 
8
- # Gunakan lifespan event handler (pengganti @app.on_event)
9
  @asynccontextmanager
10
  async def lifespan(app: FastAPI):
11
  global model
12
  print("🚀 Memuat model ResNet50 dari Hugging Face...")
 
 
13
  model = pipeline(
14
  "image-classification",
15
- model="SanketJadhav/PlantDiseaseClassifier-Resnet50",
16
- feature_extractor_kwargs={"use_fast": True} # hilangkan warning slow processor
17
  )
 
18
  print("✅ Model siap digunakan (CPU mode)")
19
  yield
20
  print("🧹 Server FastAPI dimatikan.")
 
5
  import io
6
  from contextlib import asynccontextmanager
7
 
 
8
  @asynccontextmanager
9
  async def lifespan(app: FastAPI):
10
  global model
11
  print("🚀 Memuat model ResNet50 dari Hugging Face...")
12
+
13
+ # Muat model tanpa argumen tambahan
14
  model = pipeline(
15
  "image-classification",
16
+ model="SanketJadhav/PlantDiseaseClassifier-Resnet50"
 
17
  )
18
+
19
  print("✅ Model siap digunakan (CPU mode)")
20
  yield
21
  print("🧹 Server FastAPI dimatikan.")