Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drexel 2022-2023 AIML Capstone - Digital Pathology
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zac Rahn
Drexel 2022-2023 AIML Capstone - Digital Pathology
Commits
9808c6af
Commit
9808c6af
authored
2 years ago
by
dw927
Browse files
Options
Downloads
Patches
Plain Diff
Getting images from s3 now through hard coding.
parent
7a9a03d8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
front_end/dpath.py
+3
-2
3 additions, 2 deletions
front_end/dpath.py
upload_service/app.py
+2
-1
2 additions, 1 deletion
upload_service/app.py
upload_service/diagnosis_provider.py
+36
-5
36 additions, 5 deletions
upload_service/diagnosis_provider.py
with
41 additions
and
8 deletions
front_end/dpath.py
+
3
−
2
View file @
9808c6af
...
@@ -70,8 +70,9 @@ def post_file(request) :
...
@@ -70,8 +70,9 @@ def post_file(request) :
return
response
return
response
def
image_name
(
image_url
)
:
def
image_name
(
image_url
)
:
image_name
=
image_url
.
split
(
'
/
'
)[
-
1
]
print
(
image_url
)
return
image_name
print
(
image_url
.
split
(
'
/
'
)[
-
1
])
return
image_url
.
split
(
'
/
'
)[
-
1
]
def
upload_service_url
(
image_url
)
:
def
upload_service_url
(
image_url
)
:
return
image_url
.
replace
(
'
..
'
,
REPORTS_SERVICE_URL
)
return
image_url
.
replace
(
'
..
'
,
REPORTS_SERVICE_URL
)
This diff is collapsed.
Click to expand it.
upload_service/app.py
+
2
−
1
View file @
9808c6af
...
@@ -34,6 +34,7 @@ def get_reports() :
...
@@ -34,6 +34,7 @@ def get_reports() :
@app.route
(
f
'
/
{
PREFIX
}
/report/<string:report_id>/images
'
,
methods
=
[
'
GET
'
])
@app.route
(
f
'
/
{
PREFIX
}
/report/<string:report_id>/images
'
,
methods
=
[
'
GET
'
])
def
get_images
(
report_id
)
:
def
get_images
(
report_id
)
:
provider
=
Provider
()
provider
=
Provider
()
provider
.
download_images
(
report_id
)
response
=
jsonify
(
provider
.
get_images
(
report_id
))
response
=
jsonify
(
provider
.
get_images
(
report_id
))
response
.
status_code
=
200
response
.
status_code
=
200
return
response
return
response
...
@@ -41,7 +42,7 @@ def get_images(report_id) :
...
@@ -41,7 +42,7 @@ def get_images(report_id) :
@app.route
(
f
'
/
{
PREFIX
}
/report/<string:report_id>/image/<string:file_name>
'
,
methods
=
[
'
GET
'
])
@app.route
(
f
'
/
{
PREFIX
}
/report/<string:report_id>/image/<string:file_name>
'
,
methods
=
[
'
GET
'
])
def
get_image
(
report_id
,
file_name
)
:
def
get_image
(
report_id
,
file_name
)
:
provider
=
Provider
()
provider
=
Provider
()
path
=
provider
.
get_image_path
(
file_name
)
path
=
provider
.
get_image_path
(
report_id
,
file_name
)
return
send_file
(
return
send_file
(
path
,
path
,
download_name
=
file_name
,
download_name
=
file_name
,
...
...
This diff is collapsed.
Click to expand it.
upload_service/diagnosis_provider.py
+
36
−
5
View file @
9808c6af
...
@@ -2,6 +2,8 @@ import requests
...
@@ -2,6 +2,8 @@ import requests
from
PIL
import
Image
from
PIL
import
Image
import
os
import
os
from
base64
import
b64encode
from
base64
import
b64encode
import
boto3
import
glob
BASE_URL
=
'
http://127.0.0.1:5000
'
BASE_URL
=
'
http://127.0.0.1:5000
'
SAVE_DIRECTORY
=
'
C:
\\
Users
\\
Dave
\\
OneDrive
\\
Documents
\\
Capstone
\\
data
\\
'
SAVE_DIRECTORY
=
'
C:
\\
Users
\\
Dave
\\
OneDrive
\\
Documents
\\
Capstone
\\
data
\\
'
...
@@ -21,17 +23,46 @@ class Provider:
...
@@ -21,17 +23,46 @@ class Provider:
def
get_reports
(
self
):
def
get_reports
(
self
):
url
=
BASE_URL
+
'
/request_info
'
url
=
BASE_URL
+
'
/request_info
'
return
requests
.
get
(
url
).
json
()
response
=
requests
.
get
(
url
)
return
response
.
json
()
def
get_images
(
self
,
report_id
):
def
get_images
(
self
,
report_id
):
report_id
=
'
fake_request_id
'
save_chip_path
=
f
'
../dpath/report/
{
report_id
}
/image
'
result
=
glob
.
glob
(
f
'
{
save_chip_path
}
/*.png
'
)[:
50
]
response
=
[]
response
=
[]
for
_
in
r
ange
(
50
)
:
for
i
in
r
esult
:
response
.
append
(
f
'
../dpath/report/
{
report_id
}
/image/reportimage123.png
'
)
response
.
append
(
i
.
replace
(
'
\\
'
,
'
/
'
)
)
return
response
return
response
def
get_image_path
(
self
,
image_name
):
def
download_images
(
self
,
report_id
)
:
s3_client
=
boto3
.
client
(
'
s3
'
)
s3_resource
=
boto3
.
resource
(
'
s3
'
)
image_bucket
=
s3_resource
.
Bucket
(
'
digpath-predictions
'
)
report_id
=
'
fake_request_id
'
save_chip_path
=
f
'
../dpath/report/
{
report_id
}
/image
'
dowloaded_files
=
glob
.
glob
(
f
'
{
save_chip_path
}
/*.png
'
)
prefix
=
f
'
{
report_id
}
/severe_predictions/
'
if
not
os
.
path
.
exists
(
save_chip_path
):
os
.
makedirs
(
save_chip_path
)
for
s3_obj
in
image_bucket
.
objects
.
filter
(
Prefix
=
prefix
):
if
s3_obj
.
key
==
prefix
:
continue
filename
=
s3_obj
.
key
.
split
(
'
/
'
)[
-
1
]
file_path
=
f
'
{
save_chip_path
}
/
{
filename
}
'
if
(
file_path
not
in
dowloaded_files
)
:
s3_client
.
download_file
(
'
digpath-predictions
'
,
s3_obj
.
key
,
file_path
)
def
get_image_path_old
(
self
,
image_name
):
return
SAVE_DIRECTORY
+
image_name
return
SAVE_DIRECTORY
+
image_name
def
get_image_path
(
self
,
report_id
,
image_name
)
:
report_id
=
'
fake_request_id
'
return
f
'
{
os
.
getcwd
()
}
/../dpath/report/
{
report_id
}
/image/
{
image_name
}
'
.
replace
(
'
\\
'
,
'
/
'
)
def
__save_local_file
(
self
,
file
):
def
__save_local_file
(
self
,
file
):
file_name
=
'
reportimage123.png
'
file_name
=
'
reportimage123.png
'
new_file
=
open
(
SAVE_DIRECTORY
+
file_name
,
'
wb
'
)
new_file
=
open
(
SAVE_DIRECTORY
+
file_name
,
'
wb
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment