Pranomvignesh commited on
Commit
419e1eb
·
1 Parent(s): 7901ba4

Prepared space

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -1,22 +1,52 @@
1
  import gradio as gr
2
- import torch
3
- import requests
4
- from torchvision import transforms
5
-
6
- model = torch.hub.load('pytorch/vision:v0.6.0', 'resnet18', pretrained=True).eval()
7
- response = requests.get("https://git.io/JJkYN")
8
- labels = response.text.split("\n")
9
-
10
- def predict(inp):
11
- inp = transforms.ToTensor()(inp).unsqueeze(0)
12
- with torch.no_grad():
13
- prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
14
- confidences = {labels[i]: float(prediction[i]) for i in range(1000)}
15
- return confidences
16
-
17
- demo = gr.Interface(fn=predict,
18
- inputs=gr.inputs.Image(type="pil"),
19
- outputs=gr.outputs.Label(num_top_classes=3),
20
- )
21
-
22
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import yolov5
3
+ import os
4
+ from transformers import pipeline
5
+
6
+ imageClassifier = pipeline(task="image-classification",
7
+ model="Ara88/timri-model")
8
+
9
+ model = yolov5.load('./gentle-meadow.pt', device="cpu")
10
+
11
+ def predict(image):
12
+ # results = model([image], size=224)
13
+ predictions = imageClassifier(image)
14
+ print(predictions)
15
+
16
+ return predictions
17
+
18
+
19
+ title = "Detecting Tumors in MRI Images"
20
+ description = """
21
+ Try the examples at bottom to get started.
22
+ """
23
+ examples = [
24
+ [os.path.join(os.path.abspath(''), './examples/sample_1.png')],
25
+ [os.path.join(os.path.abspath(''), './examples/sample_2.png')],
26
+ [os.path.join(os.path.abspath(''), './examples/sample_3.jpg')],
27
+ [os.path.join(os.path.abspath(''), './examples/sample_4.jpg')],
28
+ [os.path.join(os.path.abspath(''), './examples/sample_5.jpg')],
29
+ [os.path.join(os.path.abspath(''), './examples/sample_6.jpg')],
30
+ [os.path.join(os.path.abspath(''), './examples/sample_7.jpg')],
31
+ [os.path.join(os.path.abspath(''), './examples/sample_8.jpg')],
32
+ ]
33
+
34
+ inputs = gr.Image(type="pil", shape=(224, 224),
35
+ label="Upload your image for detection")
36
+
37
+ outputs = [
38
+ # gr.Image(type="pil", label="Tumor Detections"),
39
+ gr.Label(label="Tumor Classification")
40
+ ]
41
+
42
+ interface = gr.Interface(
43
+ fn=predict,
44
+ inputs=inputs,
45
+ outputs=outputs,
46
+ title=title,
47
+ examples=examples,
48
+ description=description,
49
+ cache_examples=True,
50
+ theme='huggingface'
51
+ )
52
+ interface.launch(debug=True, enable_queue=True)
examples/.DS_Store ADDED
Binary file (6.15 kB). View file
 
examples/sample_1.jpg ADDED
examples/sample_2.jpg ADDED
examples/sample_3.jpg ADDED
examples/sample_4.jpg ADDED
examples/sample_5.jpg ADDED
examples/sample_6.jpg ADDED
examples/sample_7.jpg ADDED
examples/sample_8.jpg ADDED
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
- gradio
2
  torch
3
- requests
4
- torchvision
 
 
 
 
1
  torch
2
+ yolov5
3
+ transformers
4
+ opencv-python
5
+ gradio