Tracemoepy
trace.moe python3 wrapper
Install / Use
/learn @DragSama/TracemoepyREADME
TraceMoePY
Install
- Install using pip:
pip install tracemoepy
Examples
- All the examples below are after this piece of code:
import tracemoepy
tracemoe = tracemoepy.tracemoe.TraceMoe()
- Search image using url:
resp = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
print(resp.prettify())
print(f"Match: {resp.result[0].anilist.title.romaji}\nSimilarity: {resp.result[0].similarity*100}")
- Or just file path:
print(tracemoe.search('image.jpg', upload_file=True))
- Save Video Preview:
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
output.result[0].save('preview.mp4', mute = False) # True for silent
- Save Video preview (2)
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
video = tracemoe.natural_preview(output)
with open('preview.mp4', 'wb') as f:
f.write(video)
- Save Image Preview
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
output.result[0].save(save_path = 'preview.png', preview_type="image")
- Image Preview (Method 2)
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
tracemoe.image_preview(output) # Gives content
- You can do help(method_name) to get more info about the given method
help(tracemoe.search)
Asyncio
All the examples below assume you are running this inside a async function
- Basic search (AioHttp session is not closed, You can access it as .aio_session)
import tracemoepy
tracemoe = tracemoepy.AsyncTrace()
resp = await tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
print(f"Match: {resp.result[0].anilist.title.romaji}\nSimilarity: {resp.result[0].similarity*100}")
- Auto close session
import tracemoepy
async with tracemoepy.AsyncTrace() as tracemoe:
resp = await tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
print(f"Match: {resp.result[0].anilist.title.romaji}\nSimilarity: {resp.result[0].similarity*100}")
Errors
TooManyRequests: Raised when API Limit is reached or Too many requests in short period of time.EntityTooLarge: Raised when image size is greater than max size of 10MB.ServerError: Raised when Something wrong with the trace.moe server or Image provided was malformed.InvalidToken: Raised when Invalid token was provided.EmptyImage: Raised when Image provided was empty.InvalidPath: Invalid path was given, This is only raised by.save(...)method- All these errors are located at tracemoepy.errors, Example of handling Exception:
from tracemoepy.errors import TooManyRequests
try:
# Do something
except TooManyRequests as t:
print(t)
# Do something if error
Related Skills
node-connect
337.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.3kCommit, push, and open a PR
