Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

api_test.py 520 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  1. import json
  2. from pathlib import Path
  3. import matplotlib.cm as cm
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. import requests
  7. url = 'https://mag-tiles-api.herokuapp.com/analyze'
  8. file_path = Path(
  9. 'data/MAGNETIC_TILE_SURFACE_DEFECTS/test_images/exp4_num_258590.jpg')
  10. files = {'image': (str(file_path), open(file_path, 'rb'), "image/jpeg")}
  11. response = requests.post(url, files=files)
  12. data = json.loads(response.content)
  13. pred = np.array(data['pred'])
  14. plt.imsave(f'{file_path.stem}_mask.png', pred, cmap=cm.gray)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...