shanti commited on
Commit
8ce7422
Β·
verified Β·
1 Parent(s): 0050da6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -4,7 +4,6 @@ from PIL import Image
4
  import torch
5
  from torchvision import models, transforms
6
  import requests
7
- from pyngrok import ngrok
8
 
9
  app = Flask(__name__)
10
 
@@ -17,10 +16,6 @@ imagenet_class_labels_url = 'https://raw.githubusercontent.com/anishathalye/imag
17
  response = requests.get(imagenet_class_labels_url)
18
  imagenet_class_labels = response.json()
19
 
20
- # Create Ngrok tunnel
21
- public_url = ngrok.connect(5000)
22
- print(f"πŸ”— Public URL: {public_url}")
23
-
24
  # Load pre-trained ResNet50 for object classification
25
  resnet50_model = models.resnet50(weights=models.ResNet50_Weights.DEFAULT)
26
  resnet50_model.eval()
@@ -42,7 +37,7 @@ HTML_TEMPLATE = """
42
  <html lang="en">
43
  <head>
44
  <meta charset="UTF-8">
45
- <title>🌐 AI & Image Detection</title>
46
  <style>
47
  body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f5f5f5; padding: 20px; }
48
  .container { background: white; padding: 30px; border-radius: 12px; max-width: 750px; margin: auto; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
@@ -141,4 +136,4 @@ def detect_image():
141
  )
142
 
143
  if __name__ == "__main__":
144
- app.run(port=5000)
 
4
  import torch
5
  from torchvision import models, transforms
6
  import requests
 
7
 
8
  app = Flask(__name__)
9
 
 
16
  response = requests.get(imagenet_class_labels_url)
17
  imagenet_class_labels = response.json()
18
 
 
 
 
 
19
  # Load pre-trained ResNet50 for object classification
20
  resnet50_model = models.resnet50(weights=models.ResNet50_Weights.DEFAULT)
21
  resnet50_model.eval()
 
37
  <html lang="en">
38
  <head>
39
  <meta charset="UTF-8">
40
+ <title>AI & Image Detection</title>
41
  <style>
42
  body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f5f5f5; padding: 20px; }
43
  .container { background: white; padding: 30px; border-radius: 12px; max-width: 750px; margin: auto; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
 
136
  )
137
 
138
  if __name__ == "__main__":
139
+ app.run(host="0.0.0.0", port=7860) # Updated for Hugging Face Spaces (no ngrok required)